-
Notifications
You must be signed in to change notification settings - Fork 609
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
How do add button click for each card view ? #20
Comments
the same question..please help |
Set an OnClickListener on: @Override
public Object instantiateItem(ViewGroup container, int position) And then store the current object as a tag inside that view. |
That reply doesn't seem wildly helpful if i'm honest. Where are we creating "public Object instantiateItem for example? |
Check the sample's code. The instantiateItem is called by the PagerAdapter. I'll update the sample to reflect this use case when I have time. |
Any chance you could elaborate more on that? I've tried doing what you say but I'm afraid that it seems to be beyond my skills. What would this code manifest as? I really appreciate that help |
Hi there
thanks ruben for his great work. appreciate it |
thank's dear yousof ...
…On Wed, May 9, 2018 at 9:28 PM, yousofkakhki ***@***.***> wrote:
Hi there
here you go:
` @OverRide <https://github.com/override>
public Object instantiateItem(ViewGroup container, final int position) {
View view = LayoutInflater.from(container.getContext())
.inflate(R.layout.adapter, container, false);
container.addView(view);
bind(mData.get(position), view);
CardView cardView = (CardView) view.findViewById(R.id.cardView);
cardView.setOnClickListener(new View.OnClickListener() {
@OverRide
public void onClick(View v) {
switch (position){
case 0 :
dosomething();
break;
case 1 :
dosomethingelse();
break;
}
}
});
if (mBaseElevation == 0) {
mBaseElevation = cardView.getCardElevation();
}
cardView.setMaxCardElevation(mBaseElevation * MAX_ELEVATION_FACTOR);
mViews.set(position, cardView);
return view;
}
`
thanks ruben for his great work. appreciate it
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#20 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AgL4-X3JUpopEPeaNlEizbxSFvK6KYZzks5twyAugaJpZM4Qh1GB>
.
|
Hi, i use this ... Great !
but how to add onclick listener for each card view !?
i need go to another activity when click on each card view button !
thanks
The text was updated successfully, but these errors were encountered: