代码
// 轮播
private void initLun() {
List<String> list = new ArrayList<String>();
list.add("http://172.17.8.100/images/small/banner/cj.png");
list.add("http://172.17.8.100/images/small/banner/hzp.png");
list.add("http://172.17.8.100/images/small/banner/lyq.png");
list.add("http://172.17.8.100/images/small/banner/px.png");
list.add("http://172.17.8.100/images/small/banner/wy.png");
for (int i=0; i<list.size();i++){
list.get(i);
}
flyBanner.setImagesUrl(list);
// 点击事件
flyBanner.setOnItemClickListener(new FlyBanner.OnItemClickListener() {
@Override
public void onItemClick(int position) {
Toast.makeText(getActivity(), "点击了第"+position+"照片", Toast.LENGTH_SHORT).show();
}
});
}
依赖
implementation 'com.recker.flybanner:flybanner:1.3'
布局
<com.recker.flybanner.FlyBanner
android:id="@+id/flybanner"
android:layout_width="match_parent"
android:layout_height="250dp">
</com.recker.flybanner.FlyBanner>