我在尝试在线性布局中对2个列表视图进行测试时遇到了一些问题 1列表视图(左)有修复文本,所以当右侧列表视图有更多文本时问题是2个列表视图的问题
继承活动代码:
lv1 = (ListView) findViewById (R.id.aulalist);
lv2 = (ListView) findViewById (R.id.horariolist);
String [] horarios = res.getStringArray(R.array.horarios);
lv1.setAdapter(new ArrayAdapter<String> (this, android.R.layout.simple_list_item_1, horarios));
lv2.setAdapter(new ArrayAdapter<String> (this, android.R.layout.simple_list_item_1, aula));
和布局代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="169dp"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/aulalist"
android:layout_width="169dp"
android:layout_height="fill_parent"
/>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
>
<ListView
android:id="@+id/horariolist"
android:layout_width="wrap_content"
android:layout_height="fill_parent" />
</LinearLayout>
</LinearLayout>
答案 0 :(得分:1)
您无需将ListView包含在LinearLayout中。请尝试以下代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@+id/aulalist"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1" >
</ListView>
<ListView
android:id="@+id/horariolist"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1" >
</ListView>