Android Help Button setOnclickListener -
my app works after assigning button bbtn
setonclicklistener
app doesn't load on emulator , gives me following errors :
activitymanager: starting: intent { act=android.intent.action.main cat=[android.intent.category.launcher] cmp=com.hawa.hawa_pro/.mainactivity } activitymanager: warning: activity not started, current task has been brought front
code:
package com.hawa.hawa_pro; import android.os.bundle; import android.app.actionbar.tab; import android.app.activity; import android.app.tabactivity; import android.content.intent; import android.util.log; import android.view.menu; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.tabhost; import android.content.res.resources; public class mainactivity extends tabactivity { private tabhost mtabhost; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button bbtn= (button) findviewbyid(r.id.button4); bbtn.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub intent i= new intent(mainactivity.this,beauty.class); startactivity(i); } }); resources res= getresources(); mtabhost =gettabhost(); tabhost.tabspec spec; intent intent; //home tab intent= new intent(this, home.class); spec = mtabhost.newtabspec("home") .setindicator("home",res.getdrawable(r.drawable.homebtn)) .setcontent(intent); mtabhost.addtab(spec); //won tab intent= new intent(this, about_wom.class); spec = mtabhost.newtabspec("about_wom") .setindicator("about wom",res.getdrawable(r.drawable.aboutwombtn)) .setcontent(intent); mtabhost.addtab(spec); intent= new intent(this, contact.class); spec = mtabhost.newtabspec("contact") .setindicator("contact",res.getdrawable(r.drawable.contactbtn)) .setcontent(intent); mtabhost.addtab(spec); mtabhost.setcurrenttab(0); } }
exit current app on emulator first, run app again :)
Comments
Post a Comment