【发布时间】:2014-10-18 03:01:20
【问题描述】:
我四处寻找各种解决方案,但找不到任何解决问题的方法。
我的列表视图布局(较大布局的一部分):
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:padding="@dimen/activity_horizontal_margin">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="Advantage"
android:layout_toLeftOf="@+id/tvAdvLevel"/>
<TextView
android:id="@+id/tvAdvLevel"
android:layout_width="@dimen/etOneChar"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textStyle="bold"
android:text="Level"
android:gravity="center_horizontal"/>
</RelativeLayout>
<ListView
android:id="@+id/listAdvantages"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
我用来测试填充它的代码(来自片段):
String[] strings = {"test 1", "test 2"};
ListView list = (ListView) view.findViewById(R.id.listAdvantages);
list.setAdapter(new ArrayAdapter<String>(
getActivity(), android.R.layout.simple_list_item_1, android.R.id.text1, strings));
结果(空列表视图):
它似乎确实随着它收到的数组项的数量而调整大小。没有一个只是出现。
【问题讨论】:
-
你用了一个自定义的listView,看看这个教程,它可以帮助你,只需用你的改变tem的布局,也可以将数据的对象放入listView
-
我已经尝试过了,结果相同。这就是为什么我要测试这个简单的设置是否可以工作,但事实并非如此。
标签: android listview android-listview