Callback when card is clicked
Is there any callback to know when a card is clicked? Because you can't use the normal OnClickListener since it will override the behavior.
@tushar-acharya @mustafa01ali
What exactly are you trying to do with an OnClickListener? One of the assumptions for this library is that you don't need to care about click events for individual cards, it just handles them for you and animates everything.
@mustafa01ali I want to change the card content when it is selected. So I need to know which card is selected exactly to change the content based on the id of the selected card.
You can try overloading CardStackAdapter#onClick() (https://github.com/mutualmobile/CardStackUI/blob/master/cardstack/src/main/java/com/mutualmobile/cardstack/CardStackAdapter.java#L227-L255).
@MotassemJa Am solved by overriding onTouch() , onClick() Add below code to Your Adapter(Here MyCardStackAdapter.class)
add global boolean variable for adapter(HEre MyCardStackAdapter.class) : private boolean isReadyForHide = false;
@Override
public void onClick(View v) {
super.onClick(v);
isReadyForHide = true;
v.findViewById(R.id.card_title).setVisibility(View.GONE);
//Toast.makeText(mContext, "Clicked on my postion onClick : " + v.findViewById(R.id.edtAnswer).getTag(), Toast.LENGTH_SHORT).show();
}
@Override
public boolean onTouch(View v, MotionEvent event) {
// v.findViewById(R.id.edtAnswer).setVisibility(View.VISIBLE);
if (isReadyForHide) {
v.findViewById(R.id.card_title).setVisibility(View.VISIBLE);
isReadyForHide = false;
}
// Toast.makeText(mContext, "Clicked on my postion onTouch : " + v.findViewById(R.id.edtAnswer).getTag(), Toast.LENGTH_SHORT).show();
return super.onTouch(v, event);
}