D
DrawlI
Guest
I tried to create a 2 buttons but when i click options it goes to options and when i click credits it opens options i want to open credits ;-;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b1 = (Button) findViewById(R.id.b1);
Button b2 = (Button) findViewById(R.id.b2);
b1.setOnClickListener(this);
b2.setOnClickListener(this);
}
@override
public void onClick(View v) {
switch (v.getId()){
case R.id.b1:
openOptions();
break;
case R.id.b2:
openCredits();
break;
}
}
public void openOptions(){
Intent option = new Intent(this, Options.class);
startActivity(option);
}
public void openCredits(){
Intent credit = new Intent(this, Credits.class);
startActivity(credit);
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b1 = (Button) findViewById(R.id.b1);
Button b2 = (Button) findViewById(R.id.b2);
b1.setOnClickListener(this);
b2.setOnClickListener(this);
}
@override
public void onClick(View v) {
switch (v.getId()){
case R.id.b1:
openOptions();
break;
case R.id.b2:
openCredits();
break;
}
}
public void openOptions(){
Intent option = new Intent(this, Options.class);
startActivity(option);
}
public void openCredits(){
Intent credit = new Intent(this, Credits.class);
startActivity(credit);
}