dialogplus icon indicating copy to clipboard operation
dialogplus copied to clipboard

on click listeners on item inside a custom view

Open hassan-nasr opened this issue 8 years ago • 5 comments
trafficstars

when i have a dialog with my custom view this library recursively overwrites all onClickListeners. why??? and how can i avoid this. my custom view has some functionality which is embeded inside and i don't want to change them.

hassan-nasr avatar Jun 07 '17 17:06 hassan-nasr

same problem here

alextorres50 avatar Jun 15 '17 06:06 alextorres50

Same Problem HeRE!!!!!!!!!!

Suman085 avatar Jul 04 '17 11:07 Suman085

same here. As a workaround I have forked the project and modified DialogPlus.java createView() function following way:

private View createView(LayoutInflater inflater, View headerView, View footerView, BaseAdapter adapter) {
    View view = holder.getView(inflater, rootView);

//    if (holder instanceof ViewHolder) {
//      assignClickListenerRecursively(view);
//    }

    assignClickListenerRecursively(headerView);
    holder.addHeader(headerView);

    assignClickListenerRecursively(footerView);
    holder.addFooter(footerView);

    if (adapter != null && holder instanceof HolderAdapter) {
      HolderAdapter holderAdapter = (HolderAdapter) holder;
      holderAdapter.setAdapter(adapter);
      holderAdapter.setOnItemClickListener(new OnHolderListener() {
        @Override
        public void onItemClick(Object item, View view, int position) {
          if (onItemClickListener == null) {
            return;
          }
          onItemClickListener.onItemClick(DialogPlus.this, item, view, position);
        }
      });
    }
    return view;
  }

nomyzs avatar Oct 23 '17 12:10 nomyzs

I've set onTouchListener of the component (Button) inside my custom view, and it worked by now,..

bt.setOnTouchListener((arg0, arg1) -> {
            int action = arg1.getAction();

            if (action == MotionEvent.ACTION_UP) {
                editCall();
            }
            return true;
        });

eriknyk avatar Mar 12 '18 21:03 eriknyk

👍 As I remember, we thought that it might be useful to propagate all click events through DialogPlus item click listener, but definitely there are cases it should not do that. Maybe this feature should be opt-in.

orhanobut avatar Apr 09 '18 13:04 orhanobut