标签: android-tabhost

当选择标签X时,如何更改图标?

我有一个带有图标的tabhost,当选择一个标签X时,图标不会出现,因为该图标与所选标签的颜色相同.问题是:

当选择标签X时,如何更改图标?

android android-tabhost

2
推荐指数
1
解决办法
8942
查看次数

如何更改用于指示TabHost上已选中选项卡的颜色?

在android上TabHost layout,当用户选择一个标签时,标签的颜色会暂时改变.如何禁用此颜色更改,或指定选项卡更改为的颜色?

android android-tabhost

2
推荐指数
1
解决办法
6827
查看次数

Android Tabhost刷新

我有以下代码到tabhost.

tabHost.addTab(tabHost.newTabSpec("tab1")
            .setIndicator("First Text")
            .setContent(new Intent(this, class1.class)));
tabHost.addTab(tabHost.newTabSpec("tab2")
            .setIndicator("Second Text")
            .setContent(new Intent(this, class2.class)));
Run Code Online (Sandbox Code Playgroud)

如何刷新每个标签?我想这样做是因为我在显示数据库中的数据时遇到了一些问题.

坦克

java android android-tabhost

2
推荐指数
1
解决办法
1万
查看次数

Android - 如何在制表符切换后更新显示?

我有一个带TabHost和三个标签的应用程序.他是我如何创建每个标签的示例:

    intent = new Intent().setClass(this, Setup.class); //intent.getClass()
    spec = tabHost.newTabSpec("setup").setIndicator("",
                    res.getDrawable(R.drawable.tab_setup))
                    .setContent(intent);
    tabHost.addTab(spec);
Run Code Online (Sandbox Code Playgroud)

我的目标是,当您切换到新选项卡时,调用方法更新该选项卡上显示的信息.

这是一个问题:标签如何知道它已被显示?

tabs android android-intent android-tabhost

2
推荐指数
1
解决办法
6461
查看次数

如何隐藏tabhost的TabWidget

我在我的应用程序中使用tabhost.我使用下面的代码来添加意图:

TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
Resources res = getResources();

intent = new Intent().setClass(this, AActivity.class);
spec = tabHost.newTabSpec("Files").setIndicator("NAS Files", res.getDrawable(R.drawable.ic)).setContent(intent);
tabHost.addTab(spec);
Run Code Online (Sandbox Code Playgroud)

在AActivity中,我想在单击按钮时隐藏选项卡(TabWidget).然后单击两次以显示选项卡.我该怎么做?

android android-tabhost

2
推荐指数
1
解决办法
9678
查看次数

ScrollView内的TabHost强制它滚动到底部

我的问题与这个没有答案的问题非常相似,我将解释一些小的差异:

Scrollview内部的TabHost:单击Tab时始终向下滚动

我的ScrollView启动滚动到底部,显示TabHost内容而不是它上面的内容(你可以看到链接问题中的截图,它非常相似).

如果我手动向上滚动,单击不同的选项卡不会影响ScrollView,问题仅在第一次显示时出现.这是另一个问题的区别.

我试过的事情没有成功:

  1. 使ScrollView内的顶部组件可以对焦,这样他们就可以得到焦点而不是标签.
  2. 强制滚动型滚动到顶部onResume()sv.fullScroll(View.FOCUS_UP);sv.scrollTo(0, 0);.此外,初始化没有运气,但后续调用onResume()有效地将其滚动到顶部.

有关为什么会发生这种情况的任何想法?关于如何进一步调查的提示也非常受欢迎.

android android-tabhost android-scrollview

2
推荐指数
1
解决办法
1686
查看次数

如何以编程方式/动态更改TabHost的标签

我有一个tabhost创建

  this.tabHost = getTabHost();

     // Resusable TabSpec for each tab
    Intent intent;  // Reusable Intent for each tab

    // Create an Intent to launch the first Activity for the tab (to be reused)
    intent = new Intent().setClass(this, FirstGroup.class);

    // Initialize a TabSpec for the first tab and add it to the TabHost
    spec1 = tabHost.newTabSpec("FirstGroup").setIndicator("Regionlar",
            getResources().getDrawable(R.drawable.region2)) // Replace null with R.drawable.your_icon to set tab icon
                    .setContent(intent);
    tabHost.addTab(spec1);
Run Code Online (Sandbox Code Playgroud)

我想以编程方式更改tabhost的标签:"Regionlar"到"newMenuTabbar".我找不到任何例子.谢谢你的关注.

编辑:我想从"Mənzərələr"=>"secondTabitem"改变第二个tabitem的标签

intent = new Intent().setClass(this,FirstGroup.class);

    // Initialize a TabSpec for the first …
Run Code Online (Sandbox Code Playgroud)

android android-tabhost

2
推荐指数
1
解决办法
5402
查看次数

Android TabHost选项卡背景较小的高度

使用我的标签设置设计时遇到问题.所以我为tabHost中添加的每个tabspec创建了选择器.这是它的样子:

在此输入图像描述

所以这是我的标签活动:

public class TabLayouts extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tabhost);

        TabHost tabHost = getTabHost();
        tabHost.getTabWidget().setStripEnabled(false);

        TabSpec latest = tabHost.newTabSpec(getString(R.string.latest_title));
        tabHost.setBackgroundResource(R.drawable.tabbar);

        // setting Title and Icon for the Tab
        latest.setIndicator(getString(R.string.latest_title), getResources().getDrawable(R.drawable.latest_albums_sel));
        Intent latestAlbums = new Intent(this, LatestAlbums.class);
        latest.setContent(latestAlbums);

        TabSpec favorites = tabHost.newTabSpec(getString(R.string.favorites_title));
        favorites.setIndicator(getString(R.string.favorites_title), getResources().getDrawable(R.drawable.favorites_sel));
        Intent favoritesInt = new Intent(this, Favorites.class);
        favorites.setContent(favoritesInt);

        TabSpec downloaded = tabHost.newTabSpec(getString(R.string.downloaded_title));
        downloaded.setIndicator(getString(R.string.downloaded_title), getResources().getDrawable(R.drawable.downloaded_sel));
        Intent downloadedIntent = new Intent(this, Downloaded.class);
        downloaded.setContent(downloadedIntent);

        tabHost.addTab(latest);
        tabHost.addTab(favorites); …
Run Code Online (Sandbox Code Playgroud)

android android-tabhost android-tabs

2
推荐指数
1
解决办法
1309
查看次数

Android TabHost - 收回按钮

我有一个使用TabHost的Android应用程序,根据所选标签调用其他活动的活动简称为Main.java.我试图覆盖Main.java类中的on back按钮事件,但它似乎没有看到它.我正在尝试显示一个对话框窗口,并与用户确认他们要退出,如果他们单击确定让它完全关闭应用程序(不只是发送到后台),如果他们单击取消,显然它保持打开状态.有关为什么这似乎不起作用的任何建议?

@Override
public void onBackPressed() 
{               
     AlertDialog.Builder alert = new AlertDialog.Builder(getApplicationContext());
     alert.setMessage("Test dialog");
     alert.show();
}
Run Code Online (Sandbox Code Playgroud)

confirm android dialog back android-tabhost

2
推荐指数
1
解决办法
1712
查看次数

如何更改选项卡指示器的颜色

我在我的应用程序中使用tabHost,并且要求是当选择任何选项卡时,选项卡指示器的颜色应该更改,我参考此示例如何在Android中设置选项卡视图指示器背景颜色但我不理解这是我的代码:

    TabHost tabHost = getTabHost();  // The activity TabHost

            TabHost.TabSpec spec;  // Reusable TabSpec for each tab
            Intent intent;  // Reusable Intent for each tab

            // Create an Intent to launch an Activity for the tab (to be reused)
            intent = new Intent().setClass(this, HomePage.class);
            // Initialize a TabSpec for each tab and add it to the TabHost
            spec = tabHost.newTabSpec("tabOne");  
            spec.setContent(intent);  
            spec.setIndicator("Home");  
            tabHost.addTab(spec);
            // Squash the tab a little bit horizontally
            tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = 40;
            tabHost.getTabWidget().getChildAt(0).getLayoutParams().width = 50;

            // …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-tabhost android-tabs

2
推荐指数
1
解决办法
2万
查看次数