0
當我在TabHost中的標籤之間點擊時,我需要改變我的標籤頁的drawables的alpha值。我這樣做:Drawables Alpha改變TabHost標籤切換
getTabHost().setOnTabChangedListener(new OnTabChangeListener() {
public void onTabChanged(String tabId) {
Activity currentActivity = getCurrentActivity();
Log.i("choosed activity", currentActivity.toString());
if (currentActivity instanceof LoginActivity) {
Log.i("current activity", "LoginActivity");
getResources().getDrawable(R.drawable.login).setAlpha(255);
getResources().getDrawable(R.drawable.signup).setAlpha(80);
getResources().getDrawable(R.drawable.close).setAlpha(80);
}
if (currentActivity instanceof RegisterActivity) {
Log.i("current activity", "RegisterActivity");
getResources().getDrawable(R.drawable.login).setAlpha(80);
getResources().getDrawable(R.drawable.signup).setAlpha(255);
getResources().getDrawable(R.drawable.close).setAlpha(80);
}
});
當前活動確定成功,但alpha只在我翻過設備時纔會改變。請告訴我,我該如何解決這個問題?