java - Android EditText Content is Empty, Even When Text is Shown -


i have edittext field represents id number. field can either filled programmatically, using idfield.settext(string) based on results of card swipe, or can filled manually using keyboard.

once text filled both methods (auto login--based on swipe, or manual--based on button click) both run same sign in script. when go grab contents of edittext field, if edited text manually empty string returned. if text set programmatically works perfectly.

this doesn't make sense me. there reason edittext.gettext().tostring() not return content visibly shown in textbox?

xml:

<button     android:id="@+id/btn_swipecard"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignbottom="@+id/signinid"     android:layout_toleftof="@+id/textview1"     android:onclick="signinstudent"     android:text="swipe id" /> 

button initialization:

idfield = (edittext) layout.findviewbyid (r.id.signinid); loginbutton = (button) findviewbyid(r.id.button1); loginbutton.setonclicklistener(new onclicklistener() { public void onclick(view v) { signinstudent(); } } ); 

card swipe:

// displays data card swiping private runnable doupdatetvs = new runnable() {     public void run()     {         try         {             //grab id number             string[] splitmsg = strmsrdata.split("=");             //txtidnumber.settext(splitmsg[2]);             idfield.settext(splitmsg[2]);             stringbuffer hexstring = new stringbuffer();             hexstring.append("<");             string fix = null;             (int = 0; < msrdata.length; i++) {                 fix = integer.tohexstring(0xff & msrdata[i]);                 if(fix.length()==1)                     fix = "0"+fix;                 hexstring.append(fix);                 if((i+1)%4==0&&i!=(msrdata.length-1))                     hexstring.append(' ');             }             hexstring.append(">");             myunimagreader.writelogintofile(hexstring.tostring());              signinstudent();         }         catch(exception ex)         {             ex.printstacktrace();         }     } }; 

sign in logic:

public void signinstudent() {     string temp = "http://wwww.tempurl.com/signin?id="+ idfield.gettext().tostring() + "&deviceid="+key;     webview.loadurl(temp); } 

the layout updated during oncreate phase of loop. fired when onresume event called explains why fields update after lock , unlock device. there few workarounds such doing more background processing , creating new view correct values, or using surfaceview allows drawing occur while program in normal execute cycle.

for application either background processing , move new view, or have view keeps calling oncreate events fire again. solution depends on application, that's why problem occurs.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -