Open caiovitord opened 7 years ago
You can use the code from the demo in ListViewExample:
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
((SwipeLayout)(mListView.getChildAt(position - mListView.getFirstVisiblePosition()))).open(true);
}
});
You should also be able to do inside the adapter, unlike the demo, using the same method, setOnClickListener and calling open() on SwipeLayout.
@joaolisboa You can't, because SwipeLayout is intercepting any touches, so click is not trigger.
Maybe it's been a while and things have changed but that code was literal copy/paste from a project of mine, only changed variables names. Unless you mean doing it within the adapter as I mentioned at the bottom, which I don't remember whether I tested or not.
You can do it using the SurfaceView onClickListener(). Place the below onClickListener in the adapter class.
viewHolder.swipeLayout.getSurfaceView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
viewHolder.swipeLayout.open(true);
}
});
Above onClickListener() works great even as an onClick for any item in the ListView/RecyclerView and unlike the onItemClickListener(), this is not called multiple times even when just swiping. I'm using this.
How can i do the behavior just like the setClickToClose(boolean) but to open de layout ?