android - trying to take text from one activity and print to text activity but it fails -


there no error present in code below, first activity works good,but on click button stops(crash)

help me that

public class mainactivity extends activity {  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      final edittext et = (edittext) findviewbyid(r.id.textview1);      button b1 = (button) findviewbyid(r.id.button1);      b1.setonclicklistener(new onclicklistener() {      public void onclick(view v) {          intent intent =new intent(mainactivity.this, second.class);         intent.putextra("thetv",et.gettext().tostring() );         startactivity(intent);     } }); }     }  public class second extends activity {  @override protected void oncreate(bundle savedinstancestate) {     // todo auto-generated method stub     super.oncreate(savedinstancestate);     setcontentview(r.layout.second) ;                        textview tv = (textview) findviewbyid(r.id.textview1);         tv.settext(getintent().getextras().getstring("thetv")); } } 

logcat data

05-19 21:51:06.089: w/keycharactermap(1561): no keyboard id 0

05-19 21:51:06.089: w/keycharactermap(1561): using default keymap: /system/usr/keychars/qwerty.kcm.bin

05-19 21:51:15.659: d/androidruntime(1561): shutting down vm

05-19 21:51:15.659: w/dalvikvm(1561): threadid=1: thread exiting uncaught exception (group=0x40015560)

05-19 21:51:15.669: e/androidruntime(1561): fatal exception: main

05-19 21:51:15.669: e/androidruntime(1561): java.lang.nullpointerexception

05-19 21:51:15.669: e/androidruntime(1561): @ com.nav.activitieslearn.mainactivity$1.onclick(mainactivity.java:26)

05-19 21:51:15.669: e/androidruntime(1561): @ android.view.view.performclick(view.java:2485)

05-19 21:51:15.669: e/androidruntime(1561): @ android.view.view$performclick.run(view.java:9080)

05-19 21:51:15.669: e/androidruntime(1561): @ android.os.handler.handlecallback(handler.java:587)

05-19 21:51:15.669: e/androidruntime(1561): @ android.os.handler.dispatchmessage(handler.java:92)

05-19 21:51:15.669: e/androidruntime(1561): @ android.os.looper.loop(looper.java:123)

05-19 21:51:15.669: e/androidruntime(1561): @ android.app.activitythread.main(activitythread.java:3683)

05-19 21:51:15.669: e/androidruntime(1561): @ java.lang.reflect.method.invokenative(native method)

05-19 21:51:15.669: e/androidruntime(1561): @ java.lang.reflect.method.invoke(method.java:507)

05-19 21:51:15.669: e/androidruntime(1561): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:839)

05-19 21:51:15.669: e/androidruntime(1561): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:597)

05-19 21:51:15.669: e/androidruntime(1561): @ dalvik.system.nativestart.main(native method)

05-19 21:51:19.538: i/process(1561): sending signal. pid: 1561 sig: 9

android manifest

<application     android:allowbackup="true"     android:icon="@drawable/ic_launcher"     android:label="@string/app_name"     android:theme="@style/apptheme" >     <activity         android:name="com.nav.activitieslearn.mainactivity"         android:label="@string/app_name" >         <intent-filter>             <action android:name="android.intent.action.main" />              <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity>      <activity android:name="com.nav.activitieslearn.second" >      </activity>  </application> 

check these lines,

in activity 1:

final edittext et = (edittext) findviewbyid(r.id.textview1);

in activity 2:

textview tv = (textview) findviewbyid(r.id.textview1);

it should (i guess):

in activity 1:

final edittext et = (edittext) findviewbyid(r.id.edittext1);

in activity 2:

textview tv = (textview) findviewbyid(r.id.textview1);

try correction , see whether works or not.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -