I'm using Spinner,EditText and Button in one page.The spinner has these items ...
Following:
 String[] Items = {
            "Alarm",
            "Office",
            "Meeting",
            "Party",
            "Lunch",
            "Breakfast",
            "Supper",
            "Home",
            "Private",
            "Outdoor",
            "Family",
            "Friends",
            "others"
    };
    Spinner s1;
In it if I select the "others" in spinner items means only the Edittext has to be enable otherwise it has to be disabled.If I select some other item Edittext has to be disabled
Code snippet:
s1 = (Spinner) findViewById(R.id.spinner);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
        android.R.layout.simple_spinner_item, Items);
    s1.setAdapter(adapter);
    s1.setOnItemSelectedListener(new OnItemSelectedListener()
    {
        public void onItemSelected(AdapterView<?> arg0, 
        View arg1, int arg2, long arg3) 
        {
            int index = s1.getSelectedItemPosition();
            Toast.makeText(getBaseContext(), 
                "You have selected item : " + Items[index], 
                Toast.LENGTH_SHORT).show();                
        }
        public void onNothingSelected(AdapterView<?> arg0) {}
    });
Thank you,
Do this,
    EditText edit = (EditText) findViewById(R.id.EditText01);
    edit.setEnabled(false);
    edit.setInputType(InputType.TYPE_NULL);
    edit.setFocusable(false);
And when any other option selected do this,
    edit.setEnabled(true);
    edit.setInputType(InputType.TYPE_CLASS_TEXT);
    edit.setFocusable(true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With