我有一个最近出现的奇怪问题。起初我在我的ListView中加载所有项目。它滚动一切都很好。项目是可点击的,并且一切正常。ListView in TabHost滚动/点击问题
然后在我的适配器的getView我补充说:
if(pos == getCount() - 1){
Log.i("Load", "Load database");
load_database(getCount(), 5);
}
,这里是load_database()
private void load_database(long offset, long count) {
ArrayList<VKContent> objs = BaseApplication.db.get_all(Message.class, MessageHandler.COLUMN_MAILBOX + " = " + mailbox, count, offset);
for(VKContent obj: objs){
adp.add((Message)obj);
}
}
的问题出现后,正确的。一旦加载,它会调用load_database一次,一切都很好。 ListView工作正常。点击处理。但一旦达到“pos == getCount() - 1”。它加载新的数据,但现在无法点击项目。当我滚动并退缩时,屏幕上的触摸不会停止退缩。当我在退缩时尝试滚动时,它在退出停止之前没有任何效果。
如果我切换到不同的Tab,则listview行为被恢复。如果我尝试用我的滚动球来聚焦物品,那么正常的行为也会回来。
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@android:id/tabhost">
<LinearLayout
android:orientation="vertical"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TabWidget android:id="@android:id/tabs"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<FrameLayout android:id="@android:id/tabcontent"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_weight="1">
<LinearLayout android:id="@+id/tab2"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<ListView android:id="@+id/lv"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:clickable="true" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
编辑
我曾尝试无效(),forceLayout(),requestLayout(),isFocusable()... ... bringToFront和load_database后等。但没有任何帮助。
编辑2 几乎忘了那段代码。
tabHost.setCurrentTab(1);
tabHost.setCurrentTab(0);
由于某些原因,TabHost存在问题。我的ListView由所有选项卡共享。第一次加载视图时,它不显示任何内容。所以我不得不从第二个标签切换到第一个标签。