Creating a custom OnClickListener

后端 未结 4 531
无人及你
无人及你 2020-12-30 10:00

I have an ArrayList of Buttons where my OCL needs to know which index I has been pressed. The plan is something like this:

MyOnClickListener onClickListener          


        
4条回答
  •  梦谈多话
    2020-12-30 10:40

    View.OnClickListener myListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d("Button",v.getText().tostring);
        }
    });
    

    you will get your button value in view so, you will find it which index is.

提交回复
热议问题