Swipecards
Swipecards copied to clipboard
Manage buttons inside a card
How to add a button inside a card to set like or dislike? I know that the example have buttons left and right but out of card_content.xml
Call SwipeFlingAdapterView.getTopCardListener()
in your onClick()
to obtain the listener and call .selectLeft()
or selectRight()
on that depending on which view was clicked.
Thanks for your reply. But I can't get the onClick() of each button, because there are in the card_content.xml. In the example you have this:
@OnClick(R.id.right)
public void right() {
/**
* Trigger the right event manually.
*/
flingContainer.getTopCardListener().selectRight();
}
but I can't get R.id.right of card_content.xml
The framework you're using that supplies the @OnClick
annotation might not be able to find R.id.right
because it's inflated outside of the inflation of the fragment or activity. Set the click listener manually when inflating the card (in your adapter's getView()
).
Thanks Alex. I will try this and tell you
@fedemione were you able to get this working? I have my click listener set up in my custom adapter but I am not sure how to use getTopCardListener().selectRight() from within the adapter
@fedemione were you able to get this working? I have my click listener set up in my custom adapter but I am not sure how to use getTopCardListener().selectRight() from within the adapter
did you manage to reach "getTopCardListener().selectRight()" from the adapter? I have the same issue now.
@szjktms94 did you manage to fix the issue? I have the same issue too.