我有一个包含 ListView 的子 Activity。此活动从 SQLite 游标异步填充。列表项包含一个 TextView、一个 RadioButton 和一个普通 Button。XML 如下所示:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/rlCategoryListItemLayout" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:id="@+id/tvCategoryListItemTitle" style="@style/uwLargeListItemLabelStyle" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerVertical="true" android:singleLine="true" android:text="This is a test note title" />
<LinearLayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentRight="true" android:gravity="center_vertical">
<RadioButton android:id="@+id/rdoCategoryListItemSelect" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginRight="10dip" />
<Button android:id="@+id/btnCategoryListItemDelete" android:background="@drawable/delete_red" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" />
</LinearLayout>
</RelativeLayout>
我必须做一些逻辑来确定默认选择哪个 RadioButton,并且在 ListView 已经加载之前我不能这样做。问题是到目前为止我尝试过的所有事件(onCreate、onPostCreate、onResume、onWindowFocusChanged),ListView 子计数为零。我也尝试过在 ArrayAdapter 类中使用 getView 方法,但是该方法被称为多次,并且 ListView 子计数每次都可能不同,从而导致意外结果。显然,这些事件在 ListView 完成完全填充其子项之前触发。
是否有我可以监听的事件,或其他方式来确定 ListView 何时完成填充并且所有子视图都可以通过编程方式进行修改?
谢谢!