Comments (7)
the same question..please help
from viewpagercards.
Set an OnClickListener on:
@Override
public Object instantiateItem(ViewGroup container, int position)
And then store the current object as a tag inside that view.
In the OnClick(View view), retrieve the object from that tag.
from viewpagercards.
That reply doesn't seem wildly helpful if i'm honest.
Where are we creating "public Object instantiateItem for example?
from viewpagercards.
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.
from viewpagercards.
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
from viewpagercards.
Hi there
here you go:
` @nonnull
@OverRide
public Object instantiateItem(@nonnull 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);
View.OnClickListener onClickListener = null;
switch (position) {
case 0:
onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
something();
}
};
break;
case 1:
onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
somethingElse();
}
};
break;
}
cardView.setOnClickListener(onClickListener);
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
from viewpagercards.
from viewpagercards.
Related Issues (20)
- ViewPager card distance HOT 5
- 你好,请问这个可以支持无限循环吗? HOT 2
- Could the item be click? and show a toast? HOT 2
- enableScaling ui bug
- Card view scale
- how to let it cycle HOT 1
- Rtl ViewPager
- Buttons and Images HOT 1
- how set item width?Disable the item width
- How do you Know the swiped card details
- How to make multiple CardView on page ? HOT 1
- it occurs a problem when data.Size = 1 HOT 1
- How to add library in my project
- How to add library in my project
- 如何进行数据适配 像ViewHolder一样
- Listeners when move from one Card to other
- Added AndroidX Support. Do Check!
- 为什么使用了两种方式实现?
- How to add new fragment
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from viewpagercards.