我想要制作一个小应用程序,其中MainActivity
中有4个按钮,并且每个按钮都被编码为其特定类别,但是当我按下第一个按钮时,它会重新打开MainActivity
而不是特定的页面,其余按钮不起作用。不按照代码工作的按钮
如何解决这个问题?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Doubles = (Button) findViewById(R.id.button1);
Singles = (Button) findViewById(R.id.button2);
total = (Button) findViewById(R.id.button3);
score = (Button) findViewById(R.id.button4);
Doubles.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent myintent1 = new Intent(MainActivity.this, Doubles.class);
startActivity(myintent1);
}
});