【发布时间】:2014-06-13 04:50:32
【问题描述】:
我正在制作一个需要更改ActionBarTabs 的指示器颜色的android 应用程序。我正在使用 Sherlock 库来实现ActionBarTabs。
如何更改 Sherlock ActionBar 中 ActionBarTabs 的默认指示器颜色?
ActionBar actionBar = getSupportActionBar();
// Hide Actionbar Icon
actionBar.setDisplayShowHomeEnabled(false);
// Hide Actionbar Title
actionBar.setDisplayShowTitleEnabled(false);
// Create Actionbar Tabs
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
tariffPlanJSON = getIntent().getExtras().getString("jsondata");
try {
JSONObject jsonObject = new JSONObject(tariffPlanJSON);
JSONArray jsonArray = jsonObject.getJSONArray("payload");
// going through the all tariff plans to see payload has which types of plans.
for(int index = 0; index < jsonArray.length(); index++) {
tariffPlan.add(jsonArray.getJSONObject(index).getString("plantype"));
}
} catch (JSONException e) {
e.printStackTrace();
}
Iterator<String> tariffPlansIterator = tariffPlan.iterator();
mActionBarTab = new Tab[tariffPlan.size()];
int index = 0;
while(tariffPlansIterator.hasNext()) {
String planType = tariffPlansIterator.next();
// creating a new tabs and setting the text to it.
mActionBarTab[index] = actionBar.newTab().setText(planType);
mActionBarTab[index].setTabListener(this);
actionBar.addTab(mActionBarTab[index]);
++index;
}
提前致谢。
【问题讨论】:
-
你的意思是标签下的栏?
-
您可以使用 xml 样式(请参阅@Payeli 链接的答案),但不能以编程方式。
标签: android android-actionbar actionbarsherlock