2012-02-25 16 views
2

私はこのコミュニティだけでなく、アンドロイドの開発に慣れています。 私の研究のために、(はい/いいえ)アンケートを3つのグループに分けて作成する必要があります。質問の一部がかなり長いので、その一部を大きなテキストとして、下の他の部分を小さなものとして作りたいと思います。 dev.and.comとTabLayoutを作ったのチュートリアルから各タブのチェックボックス付きリスト

私は一瞬のために私はまた私の質問のためのLinearLayout同じ

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout android:id="@+id/LinearLayout01" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    > 

    <LinearLayout 
    android:orientation="vertical" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:padding="2dp"> 

    <TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/text_large" 
    android:textSize="16sp"> 
    </TextView> 
    <TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/text_small" 
    android:textSize="12sp"> 
    </TextView> 
    </LinearLayout> 
    <LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:padding="2dp" 
    android:gravity="right"> 
    <CheckBox 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/checkBxc"> 

    </CheckBox> 
    </LinearLayout> 
    </LinearLayout> 

は、すべてのグループのためになるだろうしています。

tabLayoutのコードはhere

のようなもので、AgroupActivityだけ(テスト目的のために)今のテキストの行を表示します。

レイアウトを自分の各タブのリストのようにするにはどうすればよいですか?あるいは、他にもいくつかの可能性がありますか?私が理解したように、単純なListViewは、そのタグに何も(私の場合はチェックボックス)を持つことができません?

答えて

0

リストビューを使用して、各タブのリストのようなレイアウトの外観を表示できます。リストビュー内の各列のための

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 
    <ListView android:id="@+id/android:list" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"/> 
</LinearLayout> 

とカスタム行(your_custom_row.xml):

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     > 
     <TableRow 
     android:gravity="left" 
     > 
     <TextView 
      android:id="@+id/row_textview1" 
      android:textSize="25sp" 
      android:textStyle="bold" 
      android:layout_width="200dp" 
      android:layout_height="wrap_content" 
      android:lines="1"/> 
     <TextView 
      android:id="@+id/row_textview2" 
      android:textSize="16sp"  
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:gravity="right" 
      android:paddingRight="10dp" 
      android:lines="1"/> 
     </TableRow> 
    </TableLayout> 

とあなたのListViewコントロールにデータをバインドするアダプタを使用しますが、各タブのリストビューを使用して、各タブの内容で 。

+0

しかし問題は、質問の横にチェックボックスが必要ですが、リストビューにはテキスト行しか格納できないということですか? – user1232884

+0

TextView、ImageView、Checkbox ...をListViewに格納することができます。私はあなたに行を表示するためにTableLayoutを使用するカスタム行の例を示しました – PhatHV

+0

list_rowを水平レイアウトに設定し、隣り合わせに項目を配置することができます。 – maebe

関連する問題