根据Spinner
选择,我替换的表应更改为不可见,但如果它大于新表,则仍会显示一些旧行。当我再次选择相同的选项时,它会正确消失。
示例代码
Spinner s;
s.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
// your code here
textSpinner = s.getSelectedItem().toString();
switch (position){
case 0:
tableLayout2.setVisibility(View.INVISIBLE);
tableLayout1.setVisibility(View.VISIBLE);
break;
case 1:
tableLayout1.setVisibility(View.INVISIBLE);
tableLayout2.setVisibility(View.VISIBLE);
break;
}
}
答案 0 :(得分:2)
如果没有看到您的代码和布局,无法查明确切的问题,但使用View.GONE
代替View.INVISIBLE
可能会起作用:
switch (position){
case 0:
tableLayout2.setVisibility(View.GONE);
tableLayout1.setVisibility(View.VISIBLE);
break;
case 1:
tableLayout1.setVisibility(View.GONE);
tableLayout2.setVisibility(View.VISIBLE);
break;
}