嗨,我有兩個選項卡在我的標籤小部件,我想申請兩個不同的顏色爲兩個tabs.am到處搜索,大多數顏色都是相同的,同時應用選項卡。是否有可能在android中更改所選Tab的顏色?
更新
第一片選擇時紅色
第二個選項卡選擇時藍色
這裏我的代碼
tabHost = (TabHost)findViewById(android.R.id.tabhost);
TabSpec firstTabSpec = tabHost.newTabSpec("tid1");//these are color red
TabSpec secondTabSpec = tabHost.newTabSpec("tid1");//these color blue
firstTabSpec.setIndicator("Sales Info",getResources().getDrawable(R.drawable.sales));
Intent photosIntent = new Intent(this, a.class);
firstTabSpec.setContent(photosIntent);
secondTabSpec.setIndicator("Service Info",getResources().getDrawable(R.drawable.services));
Intent photosIntent1 = new Intent(this, b.class);
secondTabSpec.setContent(photosIntent1);
tabHost.addTab(firstTabSpec);
tabHost.addTab(secondTabSpec);
請更新我的問題 – Mercy 2012-02-20 05:43:32
@micro:請參閱我的更新回答。 – Hiral 2012-02-20 05:50:46
謝謝你的工作,但我應用顏色代碼Color.green(0xCFEB5D)而不是(color.GREEN)。它不工作爲什麼? – Mercy 2012-02-20 06:04:59