setListAdapter 方法不适用于 TabActivity
我有一个带有 3 个选项卡的 TabActivity,其中一个选项卡有一个 ListActivity。 这是我的问题,使用 setListAdapter 方法我无法再单击其他两个选项卡。我不知道为什么。有办法解决这个问题吗?
public class second extends ListActivity {
SQLiteDatabase myDB = null;
static final int MENU_NEW_KFZ = 0;
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
myDB = this.openOrCreateDatabase(HelloTab.MY_DB_NAME, MODE_PRIVATE, null);
Cursor c = myDB.rawQuery("SELECT _id, name, model FROM " + HelloTab.MY_DB_TABLE + ";", null);
startManagingCursor(c);
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_1,
c,
new String[] { "_id" },
new int[] { android.R.id.text1 });
adapter.setViewBinder(new ViewBinder() {
public boolean setViewValue(View view, Cursor theCursor, int column) {
String ColumnName = theCursor.getString(1); //Name
String ColumnModel = theCursor.getString(2); //Model
((TextView)view).setText(ColumnName + ", " + ColumnModel);
return true;
}
});
setListAdapter(adapter);
}
I have a TabActivity with 3 tabs, one of them has a ListActivity.
here is my problem, with the method setListAdapter i cant click on the other two tabs anymore. i dont know why. is there a way to solve this problem?
public class second extends ListActivity {
SQLiteDatabase myDB = null;
static final int MENU_NEW_KFZ = 0;
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
myDB = this.openOrCreateDatabase(HelloTab.MY_DB_NAME, MODE_PRIVATE, null);
Cursor c = myDB.rawQuery("SELECT _id, name, model FROM " + HelloTab.MY_DB_TABLE + ";", null);
startManagingCursor(c);
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_1,
c,
new String[] { "_id" },
new int[] { android.R.id.text1 });
adapter.setViewBinder(new ViewBinder() {
public boolean setViewValue(View view, Cursor theCursor, int column) {
String ColumnName = theCursor.getString(1); //Name
String ColumnModel = theCursor.getString(2); //Model
((TextView)view).setText(ColumnName + ", " + ColumnModel);
return true;
}
});
setListAdapter(adapter);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这些
af.notifyDataSetChanged();
其中af
是您的适配器希望它有所帮助。try these
af.notifyDataSetChanged();
whereaf
is your adpater hope it helped.