Android dynamic tab

依然范特西╮ 提交于 2019-12-11 06:58:18

问题


How create dynamic tab in android?. If user want to add tab dynamically on the tabhost. How it possible?


回答1:


check this blog.

in this example add tab by click on button

check out http://sankarganesh-info-exchange.blogspot.com/2011/04/adding-tabs-dynamically-in-android.html

another link add tab from option menu

http://knol.google.com/k/tabs-and-tabhost#




回答2:


The procedure to add a tab (whether dynamically or otherwise) is similar. You need

  1. A TabHost object
  2. A TabSpec (that you could create dynamically)
  3. tabHost.addTab() method

You need to set up the target activity for this tab in the same way that you do for creating "static" tabs (via tabSpec.setContent()).

Have you tried the Android Tab Layout tutorial? What is it that is preventing you from adding the tab dynamically?

By the way, if you do not have a view in the first place, then look at TabContentFactory.



来源:https://stackoverflow.com/questions/6869308/android-dynamic-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!