I've tried and failed repeatedly to simply have my Android emulator go from one activity to another in a program. Each attempt suddenly forces the app to close.
Here is my code for the two activites:
package dg.exe;
import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Dungeon_Main_Menu extends Activity {
private Dungeon_Main_Menu mContext;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = this;
setContentView(R.layout.main);
Button DiceRollerButton = (Button)findViewById(R.id.DiceRollerButton);
DiceRollerButton.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
Intent i = new Intent(Dungeon_Main_Menu.this, Dungeon_Dice_Roller.class);
startActivity(i);
//setContentView(R.layout.diceroller);
}
});
}
}
And the second part...
package dg.exe;
import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.EditText;
public class Dungeon_Dice_Roller extends Activity{
private Dungeon_Dice_Roller mContext;
public void onCreate(Bundle savedInstanceState){
mContext = this;
setContentView(R.layout.diceroller);
Button returnButton = (Button)findViewById(R.id.returnbutton);
returnButton.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
mContext.finish();
}
});
}
}