Просмотр списка с изображением - PullRequest
0 голосов
/ 05 марта 2012

Моя проблема заключается в том, чтобы найти лучшую конфигурацию представления для моего приложения, в которой есть запись в listView.

enter image description here

Мой main.xml имеет это содержание:

<LinearLayout android:id="@+id/tabName" android:orientation="vertical"
    android:layout_width="match_parent" android:layout_height="match_parent">
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/textConnection" android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:paddingLeft="5dp"
        android:paddingRight="5dp"
        android:minHeight="20dp"
        />
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/textTitle" android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:minHeight="40dp"
        />
    <ListView xmlns:android="http://schemas.android.com/apk/res/android" 
        android:id="@+id/listRecord" 
        android:layout_width="match_parent" android:layout_height="match_parent">
    </ListView> 
</LinearLayout>

И мой фактический ряд ListView:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView
        android:id="@+id/imageBox"
        android:layout_width="48px"
        android:layout_marginTop="13dp"
        android:layout_height="48px">
    </ImageView>
    <TextView
        android:id="@+id/longText" android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        />
    <TextView
        android:id="@+id/num1" android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        />
    <TextView
        android:id="@+id/num2" android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        />
    <TextView
        android:id="@+id/num3" android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        />
</LinearLayout>

Я пытался с TableLayout, но при запуске приложения выдает ошибку в bindView. Могу ли я написать свой XML-код только с textView? Учтите, что тогда я должен добавить заголовок ListView с тремя изображениями над каждым столбцом с номером. Спасибо-х.

1 Ответ

0 голосов
/ 05 марта 2012

Я думаю, ListView - действительно ваш лучший вариант.

Могу ли я написать свой XML-код только с textView?

Да, конечно.

Я не понимаю, в чем ваша проблема на самом деле.У вас должен быть макет активности с textConnection, textTitle, затем 3 изображениями, выровненными по правому краю (отсутствует в файле макета), и списком.
Что касается макета строки xml, я думаювсе в порядке!Просто объедините его с простым адаптером курсора в своем коде Java, и все готово.

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