TabHost不断增加动态标签,当应用程序重新启动后,后退按钮pressed [英] TabHost keeps adding the dynamic tabs when app restarts after Back Button pressed

查看:237
本文介绍了TabHost不断增加动态标签,当应用程序重新启动后,后退按钮pressed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的3个标签动态地根据这里的例子 HTTP: //developer.android.com/resources/tutorials/views/hello-tabwidget.html

I'm creating the 3 tabs dynamically based on example here http://developer.android.com/resources/tutorials/views/hello-tabwidget.html

应用效果很好,除了一个问题。
当我启动应用程序,然后单击后退按钮,然后应用程序关闭。
我通过点击应用程序图标启动应用程序。
现在我可以看到6个标签。我每次重复此过程时,它不断增加3个标签。
当过我使用的菜单按钮,而不是后退按钮,然后它不添加3个标签。

the application works well except one issue. when I launch app and then click the Back Button then the app closes. I launched the app by clicking on the application icon. now I can see 6 tabs. each time I repeat this process, it keeps on adding 3 tabs. when ever I use Menu button instead of back Button then it doesn't add 3 tabs.

什么去错在这里,我怎么能解决这个问题?

anything going wrong here, how can I fix it?

感谢

推荐答案

您创建的 onResume标签()在onStart()?尝试的onCreate创建它们()
或删除的onPause 标签的东西,如:

Are you creating the tabs at onResume() or onStart()? Try to create them at onCreate() or delete the tabs by onPause with something like:

LinearLayout tabbar = (LinearLayout) findViewById(R.id.tabbar);
tabbar.removeAllViews();

这篇关于TabHost不断增加动态标签,当应用程序重新启动后,后退按钮pressed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆