如何禁用微调器点击? setclickable(false)无效

时间:2017-04-15 12:08:54

标签: android spinner dropdown

我想禁用微调器的下拉列表,如果它只有一个项目,我几乎已经尝试了所有但仍然没有得到解决方案,有时我在尝试任何解决方案时都得到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());
        }

0 个答案:

没有答案