Android RollPagerView实现轮播图
AndroidRollPagerView实现轮播图
android图片轮播效果,RollViewPager的简单使用 
   在build.gradle(app)加载包
compile'com.jude:rollviewpager:1.2.9'
 实现代码:
//广告轮播 mViewPager=(RollPagerView)ItemView.findViewById(R.id.mViewPager); mViewPager.setAdapter(newImageLoopAdapter(getActivity(),mViewPager));
//ImageLoopAdapter.java
publicclassImageLoopAdapterextendsLoopPagerAdapter{
String[]imgs=newString[0];
privateContextmContext;
publicImageLoopAdapter(ContextmContext,RollPagerViewviewPager){
super(viewPager);
this.mContext=mContext;
}
@Override
publicViewgetView(ViewGroupcontainer,intposition){
ImageViewview=newImageView(container.getContext());
view.setScaleType(ImageView.ScaleType.CENTER_CROP);
view.setLayoutParams(newViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT));
Glide.with(mContext).load(Constants.URL[position]).into(view);
returnview;
}
@Override
publicintgetRealCount(){
returnConstants.URL.length;
}
}
 添加图片数据源:
这里可以自己设定
publicclassConstants{
publicstaticString[]URL={
"http://cdn-l.llsapp.com/connett/c3115411-3669-466d-8ef2-e6c42c690303",
"http://7xjww9.com1.z0.glb.clouddn.com/Hopetoun_falls.jpg",
"http://cdn.llsapp.com/crm_test_1449051526097.jpg",
};
}
以上就是Android实现轮播图的实例,如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!