gpt4 book ai didi

android - 如何在 Android 应用程序中创建自定义选项卡

转载 作者:太空狗 更新时间:2023-10-29 12:56:27 25 4
gpt4 key购买 nike

提前致谢..

当我在 android 应用程序中创建自定义选项卡时,主屏幕上没有显示任何选项卡

谁能告诉我如何解决这个问题?

最佳答案

你的意思是你想为你的应用程序创建自定义选项卡。好的,现在你有两个类,即 homemyclass.java 和 myclass.java。首先,您在 homemyclass.java 中声明了两行流

private Intent mytab;
private static final String TAB_MYCLASS = "myclass";

然后你在 homemyclass.java 的 onCreate() 函数中写入流水线

mytab = new Intent(this, myclass.class);
addTab(TAB_MYCLASS, getString(R.string."label for tab"), R.drawable."icon for tab display when
tab is selected", R.drawable."icon for tab display when tab is not selected", mytab);

只需将 addTab() 添加到 homemyclass.java 中

private void addTab(String tag, String label, int icon, int ficon, Intent content) {
TabHost tabHost = getTabHost();
TabSpec tabspecDialer = tabHost.newTabSpec(tag).setContent(content);

//boolean fails = true;

tabspecDialer.setIndicator(label, getResources().getDrawable(icon));


tabHost.addTab(tabspecDialer);
}

还需要通过homemyclass.java和myclass.java修改androidManifest.xml

关于android - 如何在 Android 应用程序中创建自定义选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6275928/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com