我有一个下拉菜单,我要显示从此列表中选择的盒子数。例如,如果我选择1,则仅会出现1个框。我试图通过更改可见性来做到这一点,但这不起作用
EditText editText5 = (EditText) findViewById(R.id.editText5);
public void oneBox(){
editText5.setVisibility(View.GONE);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Spinner dropdown = findViewById(R.id.spinner1);
String[] items = new String[]{"1","2","3","4","5","6"};
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, items);
dropdown.setAdapter(adapter);
dropdown.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (position==0){
oneBox();
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}