android - Get all edittext in array -


in app has 10 edittext if change in 1 edittext add total , show in textview

but how less code

or edittext onchange event edittext

i try use textwatcher watch edit text how edittext

private textwatcher filtertextwatcher = new textwatcher() {      public void aftertextchanged(editable s) {         //do stuff         string text;       }      public void beforetextchanged(charsequence s, int start, int count,             int after) {         // stuff     }      public void ontextchanged(charsequence s, int start, int before,             int count) {         // stuff      }  }; 

plz

a simple way parent viewgroup holds edittexts, loop through children, , whatever operation:

viewgroup edittextscontainer = (viewgroup) findviewbyid(r.id.edittexts_container); int sum = 0; int = edttextscontainer.getchildcount(); for(int j=0;j<i;j++) {     view child = edittextscontainer.getchildat(i);     if(child instanceof edittext) {         sum += integer.parseint((edittext)child).gettext());         // handle cases edittext text not numbers, or set inputtype in xml avoid     } } mytextview.settext(""+sum); 

code not tested, giving rough idea.


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 -