c# - Loading a string into a textview -
i need load string textview being displayed on new page after button click event. java.lang.runtimeexception keeps getting thrown when click button. "java.lang.reflect.invocationtargetexception"
here section of code:
setcontentview (resource.layout.main); button button1 = findviewbyid<button>(resource.id.story1); button1.click += delegate { setcontentview (resource.layout.next1); textview textvtest = (textview) findviewbyid(resource.id.textview1); textvtest.text = "test"; };
from first activity, in buttonclick :
button1.click += delegate { var activity2 = new intent (this, typeof(activity2)); activity2.putextra ("mydata", "test"); startactivity (activity2); };
in second activity, in oncreate()
:
protected override void oncreate (bundle bundle) { setcontentview (resource.layout.next1); textview textvtest = (textview) findviewbyid(resource.id.textview1); string text = intent.getstringextra ("mydata") ?? "data not available"; textvtest.text = text; }
Comments
Post a Comment