java - Intents issue in eclipse android -


i have issue intents. use in main activity , call activity on click call again main activity. here code

main activity.java

package com.umair.facebook;   import android.app.activity;  import android.content.intent;  import android.os.bundle;  import android.view.view;  import android.widget.button;  import android.widget.edittext;  import android.widget.imageview;  import android.widget.textview;   public class mainactivity extends activity {       imageview img1;      textview txt, txt3;      button like, share, update;      edittext et1;       @override      protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);           setcontentview(r.layout.activity_main);           img1 = (imageview) findviewbyid(r.id.img);          txt = (textview) findviewbyid(r.id.name);          txt3 = (textview) findviewbyid(r.id.status);          = (button) findviewbyid(r.id.like);          share = (button) findviewbyid(r.id.share);          update = (button) findviewbyid(r.id.comment);          et1 = (edittext) findviewbyid(r.id.edittext1);           like.setonclicklistener(new view.onclicklistener() {              @override public void onclick(view v) {                  // todo auto-generated method stub                  like.settext("liked");               }           });            share.setonclicklistener(new view.onclicklistener() {               @override               public void onclick(view v) {                   // todo auto-generated method stub                   share.settext("shared");               }           });            update.setonclicklistener(new view.onclicklistener() {               @override               public void onclick(view v) {                   // todo auto-generated method stub startgame();               }           });       }        private void startgame() {           // todo auto-generated method stub           intent lanuchgame = new intent(mainactivity.this, result.class);           startactivity(lanuchgame);        }   }  

result.java (second activity)

 package com.umair.facebook;   import android.os.bundle;   import android.widget.button;   import android.widget.edittext;   import android.widget.imageview;   import android.widget.textview;    public class result extends mainactivity {        imageview img;       textview txt1, txt2;      button btn1, btn2,btn3;       edittext et;        @override       protected void oncreate(bundle savedinstancestate) {           // todo auto-generated method stub          setcontentview(r.layout.result_1);           super.oncreate(savedinstancestate);            img =(imageview)findviewbyid(r.id.img1);           txt1= (textview)findviewbyid(r.id.nam);           txt2= (textview)findviewbyid(r.id.stats);           btn1=(button)findviewbyid(r.id.liked);           btn2=(button)findviewbyid(r.id.shared);           et=(edittext)findviewbyid(r.id.edittext); } } 

call super.oncreate(savedinstancestate) before setcontentview() in second activity.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -