android - setText from a class for another -
i new android. , english speaking not good. so,i going username using edittext
, set textview
problem edittext in first class (myactivity
),and textview
in second class(myacyivity2
). did such findviewbyid
and.... when set on click listener :
textview1.settext(edittext1.gettext())
and open app, clicking on button says: unfortunately app has stopped.
what do?
in myactivity :
edittext et = (edittext) findviewbyid(r.id.edittext1);
on button click, inside onclicklistener
:
void onclick(view view) { intent intent = new intent(myactivity.this, myactivity2.class); intent.putextra("mystring", et.gettext().tostring()); startactivity(intent); }
in myactivity2 inside oncreate()
string mystring = getintent().getstringextra("mystring"); textview tv = findviewbyid(r.id.textview1); tv.settext(mystring);
Comments
Post a Comment