我一直在痛苦一段时间,应该是相对简单的东西,但我似乎无法得到它的工作。每个ListView的数据都正确显示,我可以使用轨迹球选择并激活onItemClickListener。但是,我不能通过触摸向下滚动或选择任何项目,我知道我应该可以。任何帮助非常感谢。我的代码和XML如下:tabhost内的不可触摸的ListView
public class POITab extends TabActivity implements AdapterView.OnItemClickListener {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.poitab);
ListView raillist=(ListView)findViewById(R.id.raillist);
Cursor mrailStationsCursor = db.type_query(KEY_RAIL);
setupTab(raillist, mrailStationsCursor, "Rail", R.drawable.logo);
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.i("touched", " yes");
}
public void setupTab (ListView list, Cursor cursor, String tabname, int drawable) {
startManagingCursor(cursor);
String[] from_all = new String[]{DbAdapter.KEY_NAME};
int[] to_all = new int[] {android.R.id.text1};
list.setAdapter(new SimpleCursorAdapter(this,android.R.layout.simple_list_item_1, cursor, from_all, to_all));
list.setOnItemClickListener(this);
TabHost.TabSpec spec= getTabHost().newTabSpec(tabname);
spec.setContent(list.getId());
spec.setIndicator(tabname, getResources().getDrawable(drawable));
getTabHost().addTab(spec);
}
}
poitab.xml:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="62px">
<ListView android:id="@+id/raillist"
android:choiceMode="singleChoice"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
</ListView>
</FrameLayout>
</TabHost>`
给出了一些进一步的想法,我发现我可以滚动和选择使用触摸,但只能在模拟器和手机的屏幕底部。难道是框架布局在某种程度上覆盖了ListView? – 2011-01-31 19:30:07