1
選択時にタブのテキストの色を変更します。選択時にタブのテキストの色を変更します。
私は、セレクタXMLを試みたが、何も起こりませんでした。私はこのライブラリを使用しています:https://github.com/astuetz/PagerSlidingTabStrip
何か提案がありますか?
選択時にタブのテキストの色を変更します。選択時にタブのテキストの色を変更します。
私は、セレクタXMLを試みたが、何も起こりませんでした。私はこのライブラリを使用しています:https://github.com/astuetz/PagerSlidingTabStrip
何か提案がありますか?
あなたののonCreate(このコードスニペットを入れて、このコードスニペット
prevTab = tabHost.getCurrentTab();// Keep track of the default tab
tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener(){ //tabhost is a variable of type TabHost, which will contain all your tabs
@Override
public void onTabChanged(String id) {
int tab = tabHost.getCurrentTab();
TextView tv = (TextView) getTabWidget().getChildAt(tab).findViewById(android.R.id.title);
tv.setTextColor(Color.BLUE);//Set selected tab colour to something you want
if(prevTab!=-1){// If there was a previously selected tab, set it back to a default colour as it is now unselected
TextView tv1 = (TextView) getTabWidget().getChildAt(prevTab).findViewById(android.R.id.title);
tv1.setTextColor(Color.BLACK);
}
prevTab = tab; //Update this newly selected tab to the currently selected tab, for same logic to repeat for future tab changes
}
});
を使用することができます)すべてのタブ関連の初期化が行われた後方法。
tab.setTextColor(tabTextColor);