android - Setting data of EditText not working -
i trying set text of edittext via listview. once user chooses product listview, go activity holds edittext, , change text within edittext.
i relatively new android , java, excuse me being absolute nub.
list java:
final listview listviewcpu = (listview) findviewbyid(r.id.listviewcpu); listviewcpu.setchoicemode(listview.choice_mode_single); string cpulist[] = { "products go here", "products go here", "products go here", "products go here", "products go here", "products go here" }; arrayadapter<string> adapter = new arrayadapter<string>(this, android.r.layout.simple_list_item_1, cpulist); listviewcpu.setadapter(adapter); listviewcpu.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> listview, view myview, int pos, long mylng) { string cpu = (string) listview.getadapter().getitem(pos); intent = new intent(getapplicationcontext(), listmenuactivity.class); i.putextra(" ", cpu); startactivity(i); } }); } }
edittext java: getting error on "edittext4" defining "syntax error on token "edittext4", delete token"
edittext cpu = (edittext) findviewbyid(r.id.autocompletetextview4); cpu.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub intent cpulist = new intent(getapplicationcontext(), cpulist.class); startactivityforresult(cpulist, 0); } intent = getintent(); string product = i.getstringextra(" "); edittext cpu = ((edittext)findviewbyid(r.id.edittext4)); edittext4.settext(getintent(i).getstringextra("")); });
you set way
@override public void onitemclick(adapterview<?> listview, view myview, int pos, long mylng) { string cpu = (string) listview.getadapter().getitem(pos); intent = new intent(getapplicationcontext(), listmenuactivity.class); i.putextra("key", cpu); startactivity(i); } });
get value that
intent = getintent(); string product = i.getstringextra("key"); edittext cpu = ((edittext)findviewbyid(r.id.edittext4)); cpu.settext(product);
Comments
Post a Comment