Reputation: 14825
I have a fragment which contains a ListView
and multiple images (7-10) are displaced each time fragment is launched.
I tried using different libraries for the zooming purpose but the ListView
won't show up as then I will have to replace ImageView
with library's defined ImageView
How can I add zoom in/out for those images?
EDIT: I want to add zoom in/out to the ListView
that contain different number of images on each load, as my question states.
EDIT 2: This is getview
method of my Custom Adapter
. How do I attach PhotoViewAttacher in it?
public View getView(int position, View convertView, ViewGroup parent) {
View iv = convertView;
ViewHolder holder = null;
if (iv == null) {
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
iv = inflater.inflate(layoutResourceId, parent, false);
holder = new ViewHolder();
holder.image = (ImageView) iv.findViewById(R.id.imagview);
iv.setTag(holder);
} else {
holder = (ViewHolder) iv.getTag();
}
Picasso.with(context)
.load((Integer) data.get(position))
.resize(999, 720)
.onlyScaleDown()
.centerInside()
.into(holder.image);
return iv;
}
static class ViewHolder {
ImageView image;
PhotoViewAttacher mAttacher;
}
}
Upvotes: 2
Views: 2324
Reputation: 14825
This is how I made it work
After importing PhotoView
In layout file (if you use layout):
<uk.co.senab.photoview.PhotoView
android:id="@+id/your_photo_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
... />
And in adapter
PhotoView photoView = (PhotoView) findViewById(R.id.your_photo_view);
Picasso.with(context)
.load(file)
...
.into(photoView);
Thanks everyone for your time.
Upvotes: 1
Reputation: 25312
Instead of taking simple ImageView
in BaseAdapter
's getView
list item add
TouchImageView
Upvotes: 0