在同个ACTIVITY 里面不能创建多个按钮监听事件么?
例如:   button1.setonclicklistener(new buttonlistener);
         button2.setonclicklistener(new showlistener);   class buttonlistener implement onclicklistener{    }    class showlistener implement onclicklistener{    }
问题:不能绑定不同的按钮监听事件么?按钮

解决方案 »

  1.   

    补充:如果不行,有更好的方法实现ACTIVITY之间的跳转么?
      

  2.   

    可以设置同一个listener,通过view的ID区分出是哪一个view点击了。不过说一句,老兄,你提问的逻辑感觉是乱的,从问题上面看不出来你想要问什么。只能猜。提问是门艺术活。
      

  3.   

    我的意思是能把buttonlistener 绑在button1上面    showlistener 绑在button2上面面然后按button1跳转到activity01界面, button2跳转到activity02界面吗?
      

  4.   

    为什么ADT提示 Multiple ers at this line
    - buttonlisntenr cannot be resolved to a 
     variable
    - Syntax error on token "new", delete this 
     token
    上代码截图。。
      

  5.   

    上面的代码错了差了个括号,提示也错了,修改下  提示为: buttonlisntenr cannot be resolved to a type
      

  6.   

    老兄buttonlisntenr 后面加(),buttonlisntenr() 
      

  7.   

    上面的代码错了差了个括号,提示也错了,修改下  提示为: buttonlisntenr cannot be resolved to a type
    已经添加
      

  8.   

    你的内部内怎么缺那么多大括号啊?showbuttonlistener的大括号没加吧
      

  9.   


    你这种做法,应该没什么问题呀。不同的button,设置不同的listener。但是可以创建一个listener,在onClick里面区分是哪个button点击。这样你就不用创建多个listener.