全国免费服务热线:

18982081108
✕

成都弹性云服务器,成都高防云服务器,互联网数据服务,成都祈钰瑶

Button的四种点击事件

1.XML文件布局

创新互联拥有10多年成都网站建设工作经验,为各大企业提供网站设计制作、成都做网站服务,对于网页设计、PC网站建设(电脑版网站建设)、app软件开发公司、wap网站建设(手机版网站建设)、程序开发、网站优化(SEO优化)、微网站、申请域名等,凭借多年来在互联网的打拼,我们在互联网网站建设行业积累了很多网站制作、网站设计、网络营销经验,集策划、开发、设计、营销、管理等网站化运作于一体,具备承接各种规模类型的网站建设项目的能力。

<Button
    android:id="@+id/bt1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:onClick="doClick"
    android:text="XML添加doClick"
    android:layout_above="@+id/bt2"
    android:layout_marginBottom="47dp"
   />

<Button
    android:id="@+id/bt2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="匿名内部类"
    android:layout_marginBottom="54dp"
    android:layout_above="@+id/bt3"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<Button
    android:id="@+id/bt3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="自定义单击事件监听"
    android:layout_marginBottom="43dp"
    android:layout_above="@+id/bt4"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />
<Button
    android:id="@+id/bt4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Activity实现OnClick(View view)方法"
    android:layout_marginBottom="101dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />