当我在 TabHost 中的选项卡之间单击时,我需要更改选项卡的可绘制对象的 alpha。我这样做:
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);
}
});
Current Activity 确定成功,但只有当我翻转设备时,alpha 才会发生变化。请告诉我如何解决这个问题?