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

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -