android - EditText getText() returns different value then what is displayed -


i have been developing android while , have never come across before im hoping 1 here can help. have multiple edittext's , autocompletextviews populate sharedprefs. problem views not displaying text should be. display old value there until leave activity , come back. strange part if call gettext function on edittext when has wrong value displayed gettext() returns correct value. can please explain why might be.

public view oncreateview(layoutinflater inflater, viewgroup container,          bundle savedinstancestate){          view = inflater.inflate(r.layout.extra_info, container, false);          myprefs = preferencemanager                     .getdefaultsharedpreferences(getactivity());          initprefs();         findtextviews();         findviews();                         initdatasource();         runqueries();                    getallfields();          return view; } private void findviews() {      editpayid = (autocompletetextview)view.findviewbyid( r.id.editpayid );     editpayid.settext(payidpref);     log.e("findviews",editpayid.gettext().tostring());                   //^^ correct value screen still displays wrong value } private void initprefs(){      editor = myprefs.edit();                      payidpref = myprefs.getstring("payid", "");      log.e("payidpref", payidpref);   } 

the following code think unrelated problem maybe missing of code associated payid

editpayid.setontouchlistener(new view.ontouchlistener() {          @override         public boolean ontouch(view v, motionevent event) {              editpayid.showdropdown();             editpayid.setonitemclicklistener(new onitemclicklistener() {                  @override                     public void onitemclick(adapterview<?> arg0, view arg1,                             int arg2, long arg3) {                         string selected = editpayid.getadapter().getitem(arg2).tostring();                         editpayid.settext(selected);                         editor.putstring("payid" ,selected);                          editor.apply();                     }                                        });                 return false;             }         });         editpayid.setvalidator(new android.widget.autocompletetextview.validator() {              @override             public boolean isvalid(charsequence text) {                 log.e("in pay isvalid" , "validating");                 collections.sort(validpays);                 if (collections.binarysearch(validpays, text.tostring()) >= 0){                     return true;                 }                 return false;             }              @override             public charsequence fixtext(charsequence invalidtext) {                 editpayid.seterror("you have entered invalid payid");                 editor.putstring("payid" ,"invalid payid");                 editor.apply();                 return "invalid payid";                          }         }); 

i solved calling finsviews() , initprefs() in onresume() method. although not sure why solved issues seeing these 2 methods being called oncreate whenever cam fragment. if explain further it'd appreciated


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -