Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback when card is clicked #31

Open
MotassemJa opened this issue Jun 20, 2017 · 4 comments
Open

Callback when card is clicked #31

MotassemJa opened this issue Jun 20, 2017 · 4 comments

Comments

@MotassemJa
Copy link

MotassemJa commented Jun 20, 2017

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

@mustafa01ali
Copy link
Contributor

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.

@MotassemJa
Copy link
Author

@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.

@mustafa01ali
Copy link
Contributor

@sathishmscict
Copy link

sathishmscict commented Mar 27, 2018

@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);

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants