TabWidget tw = getTabWidget();
for (int i = 0; i < tw.getChildCount(); i++) {
View v = tw.getChildAt(i);
v.setBackgroundColor(Color.parseColor("#666666"));
}
tw.getChildAt(0).setBackgroundColor(Color.parseColor("#B21206"));
我的活動中有兩個選項卡。此代碼將第一個選項卡的顏色固定爲「紅色」,但不會使第二個選項卡在單擊時變爲「紅色」。 應該在代碼中做什麼更改?如何在點擊時更改標籤的顏色?
檢查我的編輯,並嘗試 – Akram