我想禁用微调器的下拉列表,如果它只有一个项目,我几乎已经尝试了所有但仍然没有得到解决方案,有时我在尝试任何解决方案时都得到nullpointerexception,这是我的代码。
ArrayAdapter<String> adapter =new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_spinner_item,str_fname);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sp_childName.setAdapter(adapter);
if(str_fname.length==1){
sp_childName.setBackground(null);
sp_childName.setClickable(false);
tv_childClassname.setText(str_className[0]);
}else{
sp_childName.setOnItemSelectedListener(new onItemSelected());
}