我在微调器项目选择上将按钮的可见性设置为 VISIBLE 或 GONE:-
selectUserTypeSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
FilterUserType newUserType = FilterUserType.get(position);
if(filter.userType != newUserType){
filter.userType = newUserType;
ScrollView mainScrollView = (ScrollView) findViewById(R.id.mainLayout);
switch (newUserType) {
case AnyUser:
case CurrentUser:{
selectUserBtn.setVisibility(View.GONE);
break;
}
case SpecificUser:{
selectUserBtn.setVisibility(View.VISIBLE);
break;
}
default:
break;
}
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {}
});
这里的问题是我的视图在此操作后没有刷新,但是当我在页面上选择一个 EditText 并且键盘启动时......当时它会刷新并显示所需的行为。
我尝试将 switch-case 编辑为:-
switch (newUserType) {
case AnyUser:
case CurrentUser:{
selectUserBtn.setVisibility(View.GONE);
mainScrollView.invalidate();
break;
}
case SpecificUser:{
selectUserBtn.setVisibility(View.VISIBLE);
mainScrollView.invalidate();
break;
}
default:
break;
}
}
但这也行不通
仅供参考,我HoloEverywhere
在我的项目中使用主题,这个微调器来自 HoloEverywhere 小部件。