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

Nothing happened click on card ImageView #56

Open
datomnurdin opened this issue May 6, 2015 · 2 comments
Open

Nothing happened click on card ImageView #56

datomnurdin opened this issue May 6, 2015 · 2 comments

Comments

@datomnurdin
Copy link

Nothing happened if I click the card ImageView.

cardModel.setOnClickListener(new CardModel.OnClickListener() {
            @Override
            public void OnClickListener() {
                Log.i("Swipeable Cards","I am pressing the card");
            }
        });

Please advice. Thank you.

@oscar-urbina-tech
Copy link

Thats because you are adding the clickListener into the model, you need to add clickListener into your image, this is part of my refactored code of SimpleCardStackAdapter.java. I hope it helps for you :)

@Override
public View getCardView(int position, CardModel model, View convertView, ViewGroup parent) {

    CardHolder cardHolder;

    if (convertView == null) {

        cardHolder = new CardHolder();
        final LayoutInflater inflater = LayoutInflater.from(getContext());
        convertView = inflater.inflate(R.layout.std_card_inner, parent, false);

        cardHolder.cardImage = (ImageView)convertView.findViewById(R.id.image);
        convertView.setTag(cardHolder);
    }
    else{
        cardHolder = (CardHolder)convertView.getTag();
    }      

    cardHolder.cardImage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.i(LOG_TAG, "datomnurdin touched the image! :D");
        }
    });

    return convertView;
}

/**
 * The type Card holder.
 */
static class CardHolder{

    /**
     * The Card image.
     */
    ImageView cardImage;
}

@einverne
Copy link

@ImTosS Your code works when click on the imageview in CardModel. Is there anyway to have a click listener on the entire CardModel?

einverne pushed a commit to einverne/Swipeable-Cards that referenced this issue Jun 21, 2016
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