我正在尝试将textview(id / FoundinDescubre)放在listview下面,然后放在这个textview下面的第二个listview上。我正在使用ListActivity来获取此列表视图的数据“@android:id / list”。我的xml文件看起来像这样:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1Contact"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/divider1"
>
</ListView>
<TextView
android:id="@+id/android:empty"
android:textColor="@color/text_color_white"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/main_no_items">
</TextView>
<TextView
android:layout_height="wrap_content"
android:id="@+id/FoundinDescubre"
android:layout_below="@id/android:list" -> not sure what to put here cause the listview reference id is basically coming from android.R.id.list
android:text="@string/found_in_descubre"
android:layout_width="fill_parent">
</TextView>
<ListView>
which i will worry later, I will prefer to get this textview above to show.
</ListView>
</RelativeLayout>
当它首次膨胀此布局时,id / FoundinDescubre textview正好位于与ListActivity对应的空文本视图下方。执行ListActivity后,需要几秒钟才能获得所需的数据,并在空文本视图正下方显示id / FoundinDescubre textview。创建新线程后,填充ListActivity的listview。这是textview id / FoundinDescubre在屏幕上消失的时刻。有没有办法更新或重新排列这些视图,所以id / FoundinDescubre textview可以显示在这个列表视图下面?我怀疑我是如何设置android:layout_below属性的。我不确定这是否是引用ListActivity的listview的正确方法。
我的代码还有一件事我使用runOnUiThread()调用UI线程。然后我使用来自其数组适配器的notifyDataSetChanged()修改listview。我试图从这个线程更新屏幕,但它不起作用。
RelativeLayout rlayout = (RelativeLayout) findViewById(R.id.RelativeLayout1Contact);
TextView v1 = (TextView)findViewById(R.id.FoundinDescubre);
ListView lv1 = (ListView)findViewById(android.R.id.list);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.FILL_PARENT);
lp.addRule(RelativeLayout.BELOW, lv1.getId());
rlayout.addView(v1, lp);
我不确定这个UI线程是否意味着要进行这种操作。