[英]How to add icon in tabs using drawable array
I have one activity with two fragments I am using Tabs .. It is working fine with the text in tabs . 我有一个活动,其中有两个片段,我正在使用Tabs ..与Tabs中的文本配合正常。 I want to add icons on the tabs here is the code snippet.
我想在选项卡上添加图标,这里是代码段。
analytics.java analytics.java
declaration 宣言
private String[] tabs = { "Resturant", "Market"};
int[] iconList = new int[]{R.drawable.attendance, R.drawable.analytics};
adding tabs 添加标签
for (String tab_name : tabs) {
actionBar.addTab(actionBar.newTab().setText(tab_name)
.setTabListener(this));
i++;
}
use this .. 用这个 ..
ActionBar.Tab tabA = actionBar.newTab();
tabA.setIcon(R.drawable.ic_launcher);
tabA.setText("Tab A");
actionBar.addTab(tabA);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.