0
A
回答
0
您可以使用android viewflipper。它使用起来很简单,正如您已经告诉您可以将其用于一张图片,我希望您能够找出多张图片,其余的工作可以使用viewflippper完成。
1
您还可以检查这个话题,它可以帮助我:https://es.stackoverflow.com/questions/10869/c%c3%b3mo-crear-slide-de-im%c3%a1genes-con-viewpager-y-glide-en-android?newreg=6914a57c15384b95b02e445f995490b1 **
按照本主题创建我自己的Custompageradapter这样的:
公共类CustomPagerAdapter扩展PagerAdapter {
private static final String TAG = "ImageViewPage";
Context mContext;
LayoutInflater mLayoutInflater;
String[] mResources;
public CustomPagerAdapter(Context context, String[] resources) {
mContext = context;
mResources = resources;
mLayoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return mResources.length;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
Log.d(TAG,
"instantiateItem() called with: " + "container = [" + container + "], position = [" + position + "]");
View itemView = mLayoutInflater.inflate(R.layout.item_pager, container, false);
Log.d(TAG, "load in gallery:" + mResources[position] + "#end");
final ImageView ivPhoto = (ImageView) itemView.findViewById(R.id.iv_photo);
if (!mResources[position].equals("")){
Glide.with(mContext)
.load(mResources[position].trim())
.crossFade()
.into(ivPhoto);
}
container.addView(itemView);
return itemView;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
Log.d(TAG, "destroyItem() called with: " + "container = [" + container + "], position = [" + position
+ "], object = [" + object + "]");
container.removeView((LinearLayout) object);
}
}
而要这样称呼,我这样做:
String[] photoUrls = {"http://example/photo.jpg",
"http://example2.jpeg"};
ViewPager viewPager = (ViewPager) binding.slider;
if (viewPager != null) {
viewPager.setAdapter(new CustomPagerAdapter(getContext(), photoUrls));
}
希望这有助于
相关问题
- 1. Android图库像图像滑块
- 2. Android图像滑块
- 3. 如何使用PHP的图像滑块
- 4. 动态图像滑块Android
- 5. Android图像滑块变焦
- 6. 如何 - 图像滑块
- 7. jssor嵌套的图像滑块:如何使滑块负载dynamicaly
- 8. 使用Flash Builder创建像Nivo滑块的图像滑块
- 9. 图像滑块滑入/滑出
- 10. 不能用Orbit滑块滑动图像
- 11. 如何在图像滑块中制作滑动效果?
- 12. 如何使图像滑块响应?
- 13. 如何使图像滑块在Android中使用图片来自URL
- 14. android如何打开滑块图像时onclick图像和手指滑动
- 15. 在图像滑块上使用divs
- 16. 如何在Android中使用Piccaso图像加载库来平滑图像加载?
- 17. jQuery图像滑块
- 18. javascript图像滑块
- 19. CSS图像滑块
- 20. Jssor图像滑块
- 21. jQuery图像滑块?
- 22. Java图像滑块?
- 23. webgl图像滑块
- 24. AJAX图像滑块
- 25. 滑块图像ID
- 26. 哇滑块图像
- 27. JQUERY图像滑块
- 28. Jumbotron图像滑块
- 29. 全图像滑块
- 30. 如何使用Sqlite数据库创建图像滑块?
让我试试viewflipper希望它会工作,这我期待 –