android - automatically update my activity to show which was written -


like can see here, user must provide sim card number , when number provided, fill content automatically myself adding sim card number provided. think have update automatically (autoupdate?) activity or that. if can me editing have done or presenting sample example, helpfull! thank much

the image of application here: http://imageshack.us/a/img199/1561/12216127.png

my code here:

    public class regulationtime extends activity {     @override    protected void oncreate(bundle savedinstancestate) {         edittext edit2;         super.oncreate(savedinstancestate);        setcontentview(r.layout.regulation_time);        // show button in action bar.        setupactionbar();         //récupérer le n° de la carte sim saisi par l'utilisateur        edittext edit1 = (edittext) findviewbyid(r.id.regedit1);        string simcard = edit1.gettext().tostring();         //récupérer le n° du destinataire & le saisir automatiquement dans l'edittext        string recoverrn = masternumber.getdefaults("mehmet", regulationtime.this);        edit2 = (edittext) findviewbyid(r.id.regedit2);        edit2.settext(recoverrn);         //on rentre automatiquement le texte "#152#simcardnumber#" à la place de l'utilisateur        edittext edit3 = (edittext) findviewbyid(r.id.regedit3);        string concatenation;        if(simcard.length()>0)        {            concatenation = "#152#" + simcard + "#";            edit3.settext(concatenation);        }    }  } 

what want textwatcher. use ontextchanged() user types in "sim card" box, "content" box filling up. attach textwatcher first edittext

edit1.addtextchangedlistener(new tempwatcher()); 

and create inner class textwatcher

private class tempwatcher implements textwatcher {      @override     public void aftertextchanged(editable s) {     }      @override     public void beforetextchanged(charsequence s, int start, int count, int after) {     }      @override     public void ontextchanged(charsequence s, int start, int before, int count)      {             if (s.length() > 0)           {              string sim = s.tostring();              edit2.settext(sim);          }      } 

you want make edittexts member variables declare them before oncreate() initialize them in oncreate(). should started. wrote may need tweak variable names, error checking if needed, , such. let me know if helps

edit

public class regulationtime extends activity {    edittext edit1, edit2;   // declare them here member variables   @override    protected void oncreate(bundle savedinstancestate) {      super.oncreate(savedinstancestate);    setcontentview(r.layout.regulation_time);    // show button in action bar.    setupactionbar();     //récupérer le n° de la carte sim saisi par l'utilisateur    edit1 = (edittext) findviewbyid(r.id.regedit1);   // initialize here    string simcard = edit1.gettext().tostring();     //récupérer le n° du destinataire & le saisir automatiquement dans l'edittext    string recoverrn = masternumber.getdefaults("mehmet", regulationtime.this);    edit2 = (edittext) findviewbyid(r.id.regedit2);   // initialize here    edit2.settext(recoverrn); 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -