флажок на каждой вкладке - PullRequest
2 голосов
/ 25 февраля 2012

Я новичок в этом сообществе, а также в разработке Android. Для моего исследования мне нужно составить (да / нет) анкету, разделенную на 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 похож на здесь

А AgroupActivity прямо сейчас отображает строку текста (для целей тестирования).

Как я могу сделать свой макет похожим на список на каждой вкладке? Или, может быть, есть другие возможности? Как я понял, простой ListView не может иметь ничего (флажки в моем случае) в своем теге?

1 Ответ

0 голосов
/ 25 февраля 2012

Вы можете использовать ListView для отображения макета в виде списка на каждой вкладке.С каждым содержимым вкладки вы используете ListView для каждой вкладки:

<?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) для каждой строки в ListView:

<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>

и используете Adapter для привязки данныхк вашему ListView.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...