button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
button1.setOnClickListener(this);
button2.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Intent intent = new Intent();
switch (v.getId()) {
case R.id.button1:
//跳转页面
intent.setClass(MainActivity.this, RadioActivity.class);
startActivity(intent);
break;
case R.id.button2:
//跳转页面
intent.setClass(MainActivity.this, CheckActivity.class);
startActivity(intent);
default:
break;
}
}
}
activity_radio.xml
<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:tools=“http://schemas.android.com/tools”
android:id=”@+id/LinearLayout1″
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:orientation=“vertical”
android:layout_margin=“20sp”
tools:context=”
r e l a t i v e P a c k a g e . {relativePackage}.
r
e
l
a
t
i
v
e
P