Fly Banner

Features


Min SDK : 11
Price : Free
Language : Java

 

Download


Link : Github
Owner : FlyRecker
Source Code : Download

 

Usage

Gradle

dependencies {
compile 'com.recker.flybanner:flybanner:1.3'      
}

xml Code :

<com.recker.flybanner.FlyBanner
android:id="@+id/banner_1"
android:layout_width="match_parent"
android:layout_height="200dp"/>

Java Code :

/**
* 加载本地图片
*/
private void initLocalBanner() {
mBannerLocal = (FlyBanner) findViewById(R.id.banner_1);
List<Integer> images = new ArrayList<>();
images.add(R.drawable.img_1);
images.add(R.drawable.img_2);
images.add(R.drawable.img_3);
images.add(R.drawable.img_4);
mBannerLocal.setImages(images);
mBannerLocal.setOnItemClickListener(new FlyBanner.OnItemClickListener() {
@Override
public void onItemClick(int position) {
toast("点击了第"+position+"张图片");
}
});
}
/**
* 加载网页图片
*/
private void initNetBanner() {
mBannerNet = (FlyBanner) findViewById(R.id.banner_2);
List<String> imgesUrl = new ArrayList<>();
for (int i = 0; i < mImagesUrl.length; i++) {
imgesUrl.add(mImagesUrl[i]);
}
mBannerNet.setImagesUrl(imgesUrl);
mBannerNet.setOnItemClickListener(new FlyBanner.OnItemClickListener() {
@Override
public void onItemClick(int position) {
toast("点击了第" + position + "张图片");
}
});
}