android - Edittext want to go enable from disable after select the particular item in the spinner items -
i'm using spinner,edittext , button in 1 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 if select "others" in spinner items means edittext has enable otherwise has disabled.if select other item edittext has 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 other option selected this,
edit.setenabled(true); edit.setinputtype(inputtype.type_class_text); edit.setfocusable(true);
Comments
Post a Comment