Friday, 15 August 2014

java - get edit text value from view -



java - get edit text value from view -

i want editext value , bitmap image every view has bean created dynamically.i not getting how utilize it.i have tried details view vx.but it's not happening.here code.

please help...

public class mainactivity extends activity { edittext textin; button buttonadd; linearlayout container; view addview; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); final arraylist<string> value=new arraylist<string>(); textin = (edittext)findviewbyid(r.id.textin); buttonadd = (button)findviewbyid(r.id.add); button button = (button)findviewbyid(r.id.all); container = (linearlayout)findviewbyid(r.id.container); button.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { (int = 0, c = container.getchildcount(); < c; i++) { view vx = container.getchildat(i); } } }); buttonadd.setonclicklistener(new onclicklistener(){ @override public void onclick(view arg0) { layoutinflater layoutinflater = (layoutinflater) getbasecontext().getsystemservice(context.layout_inflater_service); addview = layoutinflater.inflate(r.layout.row, null); edittext textout = (edittext)addview.findviewbyid(r.id.textout); textout.settext(textin.gettext().tostring()); textout.addtextchangedlistener(new textwatcher() { @override public void ontextchanged(charsequence s, int start, int before, int count) { // todo auto-generated method stub } @override public void beforetextchanged(charsequence s, int start, int count, int after) { // todo auto-generated method stub } @override public void aftertextchanged(editable s) { } }); final imageview buttonimg = (imageview)addview.findviewbyid(r.id.remove); buttonimg.setonclicklistener(new onclicklistener(){ @override public void onclick(view v) { //((linearlayout)addview.getparent()).removeview(addview); buttonimg.setimageresource(r.drawable.logo); }}); container.addview(addview); }}); }

}

for retrieving text:

((edittext)vx.findviewbyid(r.id.textout)).gettext()

java android

No comments:

Post a Comment