I've been trying to make a home page with several buttons that can be tapped to lead to different activities (classes, i'm working in Eclipse). I've got one button leading to an activity fine. On copying and pasting it and changing information to match the new layout and in editing the manifest, I keep getting errors. Either the app crashes or the button remains defunct. I've followed the links below and it's still not matching correctly:
Android - Creating a new activity in Eclipse
How to start new activity on button click
http://www.youtube.com/watch?v=cv2bh53IL_Y
All of which create errors when you duplicate the work. Here's what I have below:
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity {
Button userguide;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
userguide = (Button)findViewById (R.id.userguide);
userguide.setOnClickListener (new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(MainActivity.this,userguide.class);
startActivity(intent);
}
});
}
{
Button worldinformation;
Intent startNewActivityOpen = new Intent(MainActivity.this, worldinformation.class);
startActivityForResult (startNewActivityOpen, 0);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Thanks!