如何在切换更改标签内容

问题描述:

我下面一本书的教程。在开发它,我遇到的一个典型问题。我需要知道我应该如何改变我的一个标签内容,而我是从一个选项卡移动到另一个?感谢您的任何建议。

I am following one book tutorial. While developing it, I come across a typical problem. I need to know that how should I change my content of a Tab while I move from one tab to another? thanks for any suggestions.

下面是TabActivity的一个很好的教程中,你所寻找的,

Here is a nice tutorial of TabActivity you are looking for,

标签示例

有关更改所选标签的图标,你必须为每个选项卡中的XML像这样绘制文件夹

For changing the icon of selected tab you have to create an xml for each tab like this in drawable folder

first_tab.xml
    
    

first_tab.xml

    <item android:state_selected="false"        
          android:drawable="@drawable/tab_unselected_icon"/>
    <item android:state_selected="true"        
          android:drawable="@drawable/tab_selected_icon"/>
</selector>

而在创建选项卡,你就必须使用这个XML这样的,

And the while creating tabs you have to use this xml like this,

intent = new Intent().setClass(this, Activity_name.class);
        spec = tabHost.newTabSpec("yourTab_name").setIndicator("yourTab_name",res.getDrawable(R.drawable. first_tab)).setContent(intent);
        tabHost.addTab(spec);

和你用它做。谢谢你。