大家好,我的 Activity 中有一个 xml 这是我的代码:
<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/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/listview_corners" >
</ListView>
<ListView
android:id="@+id/list2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" >
</ListView>
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Prices from:" />
<ImageView
android:id="@+id/ivprivatecell"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:src="@drawable/privatecell" />
</LinearLayout>
但是,一旦加载了 ListView ,我就根本看不到 TextView 和 ImageView 了!该怎么办 ?只有 ListView 是可见的!谢谢
最佳答案
为每个 ListView 添加 layout_weight
1:
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/listview_corners"
android:layout_weight="1">
</ListView>
<ListView
android:id="@+id/list2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="gone" >
</ListView>
关于android - listview下的textview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17926564/