wemall app商城源码中android按钮的三种响应事件

时间:2023-03-09 09:54:48
wemall app商城源码中android按钮的三种响应事件

wemall-mobile是基于WeMall的android app商城,只需要在原商城目录下上传接口文件即可完成服务端的配置,客户端可定制修改。本文分享wemall app商城源码中android按钮的三种响应事件,供技术员参考学习。

第一种:采用匿名内部类方法

 button1.setOnClickListener(new View.OnClickListener()

   {

     @Override

     public void onClick(View arg0) {

          System.out.println("button1 clicked");

        }

   });

  

第二种:修改XML Android:onClick 属性

 <Button

     android:layout_height="wrap_content"

     android:layout_width="wrap_content"

     android:text="@string/self_destruct"

     android:onClick="selfDestruct" />

     public void selfDestruct(View arg0) {

       System.out.println("button1 clicked");

   }

  

第三种:采用activity实现OnClickListener接口

public class TaskActivity extends Activity implements ClickListener

    {  

       public void onClick(View arg0)

       {

                 if(arg0==button1)

            System.out.println("button1 clicked");

                       else if (arg0==button2)

                               System.out.println("button2 clicked");

                      ...

                   }

    }

原文详情地址:http://git.oschina.net/einsqing/wemall-mobile

wemall-mobile商城详情地址:http://www.koahub.com/home/product/56

wemall官网地址:http://www.wemallshop.com

WeMall - 开源微商城 微信商城 商城源码 分销商城 b2b2c商城系统

wemall app商城源码中android按钮的三种响应事件