daimajia / AndroidSwipeLayout

The Most Powerful Swipe Layout!
MIT License
12.38k stars 2.67k forks source link

When swipe, item click event is fired #244

Open tolya199178 opened 8 years ago

tolya199178 commented 8 years ago

I swipe left to show bottom view and it's working fine. Then when I'm trying to swipe right to hide bottom view, the item click event is fired and thus onItemClick event is called in my activity. I want onItemClick() is not called if bottom view is shown. Anyone who has a solution, please let me know.

tolya199178 commented 8 years ago

I already set the attribute "clickToClose" of SwipeLayout to true. I can close the bottom view by clicking on SurfaceView and it's fine. My only trouble is for onItemClick event is firing when swipe right to close.

desnyki commented 8 years ago

try to set the onClickListener on the surface view like so

swipeLayout.getSurfaceView().setOnClickListener( ...

Mohammad699 commented 8 years ago

@desnyki Thank you a ton. this solved my problem :+1:

sahana-tib commented 8 years ago

I had the same issue. I tried the same. it works fine. But I also want the onItemClick() to be fired when it is clicked. This doesnt happen when I set swipeLayout.setOnClickListener(new OnClickListener{

 @Override
  public void onClick(View v){

}

});

Please help.

namchuai commented 8 years ago

@sahana-tib I faced this issue and this is my work around:

  1. swipeLayout.setOnClickListener... do nothing, like you've said.
  2. set onclick for a layout that you want to handle onClick in your ViewHolder.

mProductWrapper.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } });

Hope this help!

VigneshPT commented 8 years ago

@namchuai your work-around works. Thanks

coder-tan commented 8 years ago

@namchuai, step 1 is unnecessary.