mBtn1 = (Button)findViewById(R.id.mBtn1);
mBtn1 .setOnClickListener ( new new View.OnClickListener () { // click event
@Override
public void onClick (View v) { // click event of
the Intent the Intent = new new the Intent (MainActivity. the this , ButtonActivity. class ); // Jump to ButtonActivity
startActivity (Intent);
}
});
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<solid
android:color="#ff9999"
/>
<! - set the filling color Color ->
< Stroke
Android : width = "2DP"
Android : Color = "# 000000"
/>
<- edge color of the color set -!>
<corners
android:radius="10dp"
/>
<! - set the size of the fillet ->
</
shape>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false">
<shape>
<solid android:color="#ff9999"/>
<corners android:radius="10dp"/>
</shape>
</item>
<!--设置未按压时的样式-->
<item android:state_pressed="true">
<shape>
<solid android:color="#000000"/>
<corners android:radius="10dp"/>
</shape>
</item>
<!--设置按压时的样式-->
</selector>
android:background="@drawable/bg_btn" 引用格式