当我在TabHost中的标签之间点击时,我需要更改标签的drawable的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);
}
});
当前活动确定成功,但只有当我翻转设备时,alpha才会发生变化。请告诉我,我该如何解决这个问题?
答案 0 :(得分:0)
也许你应该在设置新的alpha值后尝试invalidate()