SuperAdapter icon indicating copy to clipboard operation
SuperAdapter copied to clipboard

建议新增一个获取当前item 的方法,用于监听整个item的各种事件

Open ByteRax opened this issue 10 years ago • 2 comments

我现在的做法是给item的布局添加一个id. 然后更具这个id在去监听..个人觉得多余了,我还是比较喜欢在onBind里面监听当前的item 的事件.

ByteRax avatar May 18 '16 07:05 ByteRax

holder.itemView 即可。 item事件目前支持click和longClick,如果有更多个性化的需求,建议重写onCreate()方法而不是onBind()(更省资源). 如:

@Override
public SuperViewHolder onCreate(View convertView, ViewGroup parent, int viewType) {
      SuperViewHolder holder = super.onCreate(convertView, parent, viewType);
      holder.itemView.setOnTouchListener(new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
              // do something you like.
              return false;
          }
      });
      return holder;
}

如有其它疑问,可以继续comment,谢谢反馈。

chenenyu avatar May 18 '16 08:05 chenenyu

非常感谢,就是它.

ByteRax avatar May 20 '16 03:05 ByteRax