bbtn
私のアプリはうまく動作しますが、ボタンをアプリに割り当てた後setOnClickListener
、エミュレーターに読み込まれず、次のエラーが表示されます:
ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.Hawa.hawa_pro/.MainActivity }
ActivityManager: Warning: Activity not started, its current task has been brought to the front
コード:
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);
}
}