最佳答案
您可以像这样为应用程序实现选项卡
在onCreate方法中
TabHost tabHost = getTabHost();
tabHost.setCurrentTabByTag("First");
TabSpec firstTab = tabHost.newTabSpec("First");
firstTab.setIndicator("firstTab",getResources().getDrawable(R.drawable.ic_action_first)); //drawable 1
firstTab.setContent(R.id.first_content); //View
tabHost.addTab(firstTab);
TabSpec secondTab = tabHost.newTabSpec("Second");
secondTab.setIndicator("secondTab",getResources().getDrawable(R.drawable.ic_action_second)); //drawable 2
secondTab.setContent(R.id.second_content); //View
tabHost.addTab(secondTab);
TabSpec thirdTab = tabHost.newTabSpec("Third");
thirdTab.setIndicator("thirdTab",getResources().getDrawable(R.drawable.ic_action_third)); //drawable 3
thirdTab.setContent(R.id.third_content); //View
tabHost.addTab(thirdTab);
tabHost.setCurrentTab(0);
在xml文件中
irst_content" android:layout_width="fill_parent" android:layout_height="fill_parent">
irst_tab"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
在getResources()调用你的drawable.getDrawable(R.drawable.drawableid));
原文地址:https://www.jb51.cc/android/430598.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。