ImageButton 通过点击图像,完成提交的信息

来源:互联网 发布:水产加工erp软件 编辑:程序博客网 时间:2024/05/01 08:43


ImageButton图像按钮: 通过图像点击


Layout.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="
http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageButton
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher"//设置图像资源
        android:onClick="btnOnClick" />

</RelativeLayout>


MainActivity.java


public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void btnOnClick(View view) {
     Log.d("1507", "啊!我被点击了!");
    }
   
}

0 0
原创粉丝点击