java - Can't start another activity in Android -


i'm learning android developpement, , wrote short , easy code, doesn't work. can't start activity,despite many try ! here code of main activity :

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_pageaccueil); }    @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.pageaccueil, menu);     return true; } public void oncreate1(bundle savedinstancestate) {   super.oncreate(savedinstancestate);   setcontentview(r.layout.activity_pageaccueil);    final button button = (button) findviewbyid(r.id.button1);   button.setonclicklistener(new onclicklistener() {    @override   public void onclick(view v) {     intent intent = new intent(pageaccueil.this, devise.class);     startactivity(intent);     } });    } } 

and button part of xml layout first/main activity :

    <button     android:id="@+id/button1"     style="?android:attr/buttonstylesmall"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignparentleft="true"     android:layout_alignparenttop="true"     android:layout_margintop="38dp"     android:text="convertisseur de devises"   /> 

the second activity "devise", , here code : import android.os.bundle; import android.app.activity; import android.view.menu;

 public class devise extends activity {  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      setcontentview(r.layout.activity_devise); }  @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.devise, menu);     return true; }  } 

does know how can make second activity launch ? tried many times without success .

thank in advance !!

use following in oncreate() instead of oncreate1()

final button button = (button) findviewbyid(r.id.button1);   button.setonclicklistener(new onclicklistener() {    @override   public void onclick(view v) {     intent intent = new intent(pageaccueil.this, devise.class);     startactivity(intent);     } });    } 

also study life cycle of activity http://developer.android.com/training/basics/activity-lifecycle/index.html


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -