2 番目のアクティビティを開始しようとしていますが、コードでエラーが発生します。
import android.os.Bundle;
import android.content.Intent;
import android.app.Activity;
import android.widget.Button;
import android.view.View;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewStub;
import android.widget.AdapterView;
import android.widget.ImageButton;
import android.widget.Toast;
public class MainActivity extends Activity
{
private static final int ID_SPLASH = 1;
private static final int ID_MAIN = 2;
private static final int ID_PROFILE = 3;
private static final int ID_PLAY = 4;
private static final int ID_HELP = 5;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setContentView(R.layout.main);
ImageButton menuBtn = (ImageButton)findViewById(R.id.iBtn1);
//Button example1Btn = (Button) findViewById(R.id.btn1);
ActionItem splashItem = new ActionItem(ID_SPLASH, "Splash", getResources().getDrawable(R.drawable.ic_action_about));
ActionItem mainItem = new ActionItem(ID_MAIN, "Main", getResources().getDrawable(R.drawable.ic_content_undo));
ActionItem profileItem = new ActionItem(ID_PROFILE, "Profile", getResources().getDrawable(R.drawable.ic_social_person));
ActionItem playItem = new ActionItem(ID_PLAY, "Play", getResources().getDrawable(R.drawable.ic_hardware_gamepad));
ActionItem helpItem = new ActionItem(ID_HELP, "Help", getResources().getDrawable(R.drawable.ic_action_help));
//use setSticky(true) to disable QuickAction dialog being dismissed after an item is clicked
helpItem.setSticky(true);
final QuickAction mQuickAction = new QuickAction(this);
mQuickAction.addActionItem(splashItem);
mQuickAction.addActionItem(mainItem);
mQuickAction.addActionItem(profileItem);
mQuickAction.addActionItem(playItem);
mQuickAction.addActionItem(helpItem);
//setup the action item click listener
mQuickAction.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() {
@Override
public void onItemClick(QuickAction quickAction, int pos, int actionId) {
ActionItem actionItem = quickAction.getActionItem(pos);
if (actionId == ID_SPLASH) {
Intent intent = new Intent(this, SplashActivity.class);
startActivity(intent);
} else if (actionId == ID_MAIN) {
Toast.makeText(getApplicationContext(), "Main---> item selected", Toast.LENGTH_SHORT).show();
} else if (actionId == ID_PROFILE) {
Toast.makeText(getApplicationContext(), "Profile---> item selected", Toast.LENGTH_SHORT).show();
} else if (actionId == ID_PLAY) {
Toast.makeText(getApplicationContext(), "Play---> item selected", Toast.LENGTH_SHORT).show();
} else if (actionId == ID_HELP) {
Toast.makeText(getApplicationContext(), "Help---> item selected", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), actionItem.getTitle() + " selected", Toast.LENGTH_SHORT).show();
}
}
});
mQuickAction.setOnDismissListener(new QuickAction.OnDismissListener() {
@Override
public void onDismiss() {
Toast.makeText(getApplicationContext(), "Ups..dismissed", Toast.LENGTH_SHORT).show();
}
});
menuBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mQuickAction.show(v);
}
});
}
}
新しいものからすべてが好きではありません。
指示に従っていると感じました http://developer.android.com/training/basics/firstapp/starting-activity.html