我在RelativeLayout中使用listview。在使用Efficient Adapter填充listview后,焦点移动直接转到listview的第四个元素。当listview填充项目或刷新时,我想选择列表视图的第一项。 以下是代码:
mAdapter_New.notifyDataSetChanged();
lt1.addFooterView(footerView);
lt1.setAdapter(mAdapter_New);
lt1.setSelection(0);
lt1.setSelectionAfterHeaderView();
布局文件如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@color/White">
<RelativeLayout .... >
<LinearLayout ...>
</LinearLayout>
</RelativeLayout>
<ListView
android:layout_width="fill_parent"
android:id="@+id/listtv01"
android:layout_alignParentTop="false"
android:layout_below="@+id/ril_prg"
android:layout_height="fill_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:fitsSystemWindows="true"
android:divider="@color/Grey"
android:dividerHeight="1dip"
android:headerDividersEnabled="false"
android:footerDividersEnabled="false"
android:clickable="true"
android:background="@color/White"
android:cacheColorHint="#00000000">
</ListView>