About Android button event -
hi new in android application development.i practicing android development while.here trying do:
in screen there 2 spinner named "to" , "from" , 2 edit text button named "amount" , "result".i want following:
when clear button clicked reset “to” , “from” default values , clear “amount” , “result”.
can have idea?it helpful if code. thanks.
this crude code, haven't tested, wrote on top of head, there can errors , assumed layout ids. need figure out.
public class spinnerexample extends activity { private string array_spinner[]; private spinner tospinner; private spinner fromspinner; private button btnclear; private edittext etamount; private edittext etresult; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); array_spinner=new string[3]; array_spinner[0]="1"; array_spinner[1]="2"; array_spinner[2]="3"; fromspinner = (spinner)findviewbyid(r.id.fspinner); tospinner = (spinner)findviewbyid(r.id.tspinner); arrayadapter fromadapter = new arrayadapter(this, android.r.layout.fspinneritem, array_spinner); arrayadapter toadapter = new arrayadapter(this,android.r.layout.tspinner_item,array_spinner); btnclear = (button)findviewbyid(r.id.clear_button); btnclear.setonclicklistener(new button.onclicklistener(){ public void onclick(view v){ etamount = (edittext)findviewbyid(r.id.amount_et); etresult = (edittext)findviewbyid(r.id.result_et); etamount.settext(""); etresult.settext(""); fromspinner.setadapter(fromadapter); tospinner.setadapter(toadapter); } }); } }
Comments
Post a Comment