spinner1=(Spinner) findViewById(R.id.spinner1); String [] arr={"个人","单位"};
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,arr);
spinner1.setAdapter(adapter);
spinner1.setAdapter(adapter);
spinner1.setOnItemSelectedListener(new OnItemSelectedListener() {//选择item的选择点击监听事件 public void onItemSelected(AdapterView<?> parent,View view,int position, long id) { if(spinner1.getSelectedItem().toString().equals("单位")){ invoicefirmEditText.setVisibility(View.VISIBLE); } else{ invoicefirmEditText.setVisibility(View.GONE); }//if和else缺一不可 }
效果如下:
//无编辑框