TabHost 迁移到 Honycomb 时遇到问题
在数据库驱动的 tabhost 上工作时,我在尝试迁移到 Honycomb 时遇到了问题。
我有这样的事情:
Cursor c = db.getAll();
if ( c.moveToFirst() ) {
do {
// Log tab name
Log.d("(Honycomb)", "TabSpec : " + c.getString(2));
// Set new tabspec ID
TabSpec Tab = tabHost.newTabSpec( "tid" + c.getString(1) ) ;
if( c.getString(2).equals("abc")) {
Tab.setIndicator( c.getString(2), context.getResources().getDrawable(R.anim.icon1) ) ;
} else if( c.getString(2).equals("bcd")) {
Tab.setIndicator( c.getString(2), context.getResources().getDrawable(R.anim.icon2) ) ;
}
Intent intent = new Intent() ;
intent.putExtra( "CATORDER", c.getString(1) );
intent.setClass(context, Mytab.class) ;
Tab.setContent( intent ) ;
tabHost.addTab(Tab) ;
} while ( c.moveToNext() ) ;
} else {
Toast.makeText(context, "There is nothing available.",
Toast.LENGTH_LONG).show();
}
tabHost.setOnTabChangedListener(OnTabChangeListener);
tabHost.getTabWidget().setCurrentTab(0);
db.getAll() 结果 >从数据库返回 2 条记录。在LOGCAT c.getString(2)中可以看到> 2次-值符合预期,但是查看屏幕上的tabHost,我确实显示了所有选项卡,但只有第一个选项卡显示了字符串(但是)没有任何可能的操作,并且在一段时间后返回到应用程序的启动。
如果我从 Honycomb 切换到 2.2,它会显示预期的一切吗?
MyTab 也有 log.d() ,从这里我只能在第一次找到显示,如果在 3.0 中运行,但在 2.2 中运行多次(如预期)。
看起来有些东西已经改变了(或者我在 2.2 中做了一些好的事情,但在 3.0 中却没有),但到目前为止我找不到我做错了什么。有什么想法吗?
如果我的 LOGCAT 中出现错误,我也会发布此内容,但它们似乎不存在(再次切换到 2.2 让其运行正常,并且 c.getString(2) 不仅显示 > x 次,而且还给出 的标签。
正确 右室收缩率
working on a db driven tabhost I am running into problem trying to move to Honycomb.
I have something like this:
Cursor c = db.getAll();
if ( c.moveToFirst() ) {
do {
// Log tab name
Log.d("(Honycomb)", "TabSpec : " + c.getString(2));
// Set new tabspec ID
TabSpec Tab = tabHost.newTabSpec( "tid" + c.getString(1) ) ;
if( c.getString(2).equals("abc")) {
Tab.setIndicator( c.getString(2), context.getResources().getDrawable(R.anim.icon1) ) ;
} else if( c.getString(2).equals("bcd")) {
Tab.setIndicator( c.getString(2), context.getResources().getDrawable(R.anim.icon2) ) ;
}
Intent intent = new Intent() ;
intent.putExtra( "CATORDER", c.getString(1) );
intent.setClass(context, Mytab.class) ;
Tab.setContent( intent ) ;
tabHost.addTab(Tab) ;
} while ( c.moveToNext() ) ;
} else {
Toast.makeText(context, "There is nothing available.",
Toast.LENGTH_LONG).show();
}
tabHost.setOnTabChangedListener(OnTabChangeListener);
tabHost.getTabWidget().setCurrentTab(0);
db.getAll() results in > 2 records comming back from db. In LOGCAT c.getString(2) is seen > 2 times - values as expected, however looking at tabHost on screen I do get all tabs shown BUT only first tab shown with the string (but) without any action posible and after some time return to start of app.
If I switch from Honycomb to 2.2 it shows everything expected?
Also MyTab is having log.d() and from this I only find display from this just the first time only, if running in 3.0 but multiple times (as expected) in 2.2.
Looks like something has changed (or I did something ok for 2.2 but not in 3.0) but so far I could not find what I did wrong. Any idea?
If I would have errors in my LOGCAT telling something I would post this also but they seem not to be there (again switching to 2.2 let this run ok and the c.getString(2) is not only shown > x times but also gives tabs correctly.
Regards,
RvE
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在我的案例中发现了问题。事实证明,我的 Layout xml 视图之一在 2.2 中运行时可以正常运行,但在 3.0 中运行则不行。花了一些时间才找到这个,因为我从来没有遇到过任何指向这个的错误。
因此,如果遇到类似问题,请尝试查看您的布局 xml,看看是否有某些因素导致您的应用程序内出现不需要的行为。
I found problem in my case. It turned out one of my Layout xml views had something fine if running in 2.2 but not ok in 3.0. Took some time to find this because I never had some error pointing to this at all.
So, if one is having simular issues try to look at your layout xml to see if there is something in causing unwanted behavior inside your app.