【发布时间】:2013-09-12 16:55:21
【问题描述】:
我正在创建一个自定义 ArrayAdapter,以便在 ListView (Customizing Android ListView Items with Custom ArrayAdapter) 中显示多个 TextView。我的目标是以类似表格的格式(有 2 列)显示它们,有点像这样:
甲乙 ---------- 光盘 ---------- 英法但是,我一直以垂直格式获取它们,如下所示:
一个 乙 ---------- C D ---------- 乙 F这是我的活动 xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/list_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
这里是 list_view.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView android:id="@+id/product_name"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
android:textSize="16dip"
android:textStyle="bold"/>
<TextView android:id="@+id/status"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
android:textSize="16dip"
android:textStyle="bold"/>
</LinearLayout>
我对 fill_parent 和 wrap_content 不太熟悉,也许我对它们做错了什么?
【问题讨论】: