Button Listener not get registered on first click In android

后端 未结 3 1619
死守一世寂寞
死守一世寂寞 2021-01-22 00:36

As i am new to android here i got the problem for button listeners I am using OnClickListener for busttons but it doesnot performs after first click once i clic

3条回答
  •  臣服心动
    2021-01-22 01:02

    Why do you need annonymous inner class when you have

     btnOENew.setOnClickListener(this);
    

    and your class implements OnClickListener

    All you need is switch case in onClick

    @Override
    public void onClick(View v) {
    
        switch(v.getId())
         {
           case R.id.btnOENew :
               // button btnOENew clicked
           break;
           case R.id.btnAENew :
                // button btnAENew clicked  
           break;
           ... // similar for other buttons
          }
    }
    

提交回复
热议问题