Android EditText .setText("") not working -


i trying clear text in edit text field reason not working.

i have declared edit text field in xml of view:

 <edittext         android:id="@+id/enterglucoselevel"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_below="@+id/mysimplexyplot"         android:layout_centerhorizontal="true"         android:ems="10"         android:inputtype="numberdecimal" /> 

i have used attribute onclick link button enterglucoseaction() method in mainactivity class:

<button     android:id="@+id/enterglucosebutton"     android:clickable="true"     android:onclick= "enterglucoseaction"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_below="@+id/enterglucoselevel"     android:layout_centerhorizontal="true"     android:text="@string/enterglucoselvlbutton" /> 

here method:

public void enterglucoseaction(view v) {     glucosefield.settext("");       toast.maketext(v.getcontext(), "you clicked button", toast.length_short).show(); } 

i toast pop edit text field not being cleared.

here on create , instance variables in case problem lies there.

private xyplot plot; private button addglucoselevel; private edittext glucosefield; private xyseries currentseries;  @override protected void oncreate(bundle savedinstancestate) {      super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      addglucoselevel = (button) findviewbyid(r.id.enterglucosebutton);     glucosefield = (edittext) findviewbyid(r.id.enterglucoselevel);                           currentseries = new simplexyseries(arrays.aslist(new number[] { 7200, 8, 54000, 2, 64800, 4 }),              simplexyseries.arrayformat.xy_vals_interleaved,             "glucose level");      //create series of numbers plot.     creategraph(currentseries); } 

thanks in advance.

and sorry, know has been asked before can't find solution problem specifically.

to clear edittext accepts numbers use clear() method:

glucosefield.gettext().clear(); 

you can try setting way:

((edittext)findviewbyid(r.id.enterglucoselevel)).gettext().clear(); 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -