android實(shí)現(xiàn)banner輪播圖無(wú)限輪播效果
本文實(shí)例為大家分享了banner輪播圖無(wú)限輪播效果的具體代碼,供大家參考,具體內(nèi)容如下
效果展示
第一步(權(quán)限配置)
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.VIBRATE" />
第二步(添加依賴)
compile 'com.squareup.okio:okio:1.5.0' compile 'com.squareup.okhttp3:okhttp:3.2.0' compile 'com.squareup.okhttp3:logging-interceptor:3.4.1' compile 'com.google.code.gson:gson:2.8.2' compile 'com.youth.banner:banner:1.4.9' //compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' compile 'com.github.bumptech.glide:glide:3.7.0'
第三步(加布局)
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="150dp"> <com.youth.banner.Banner android:id="@+id/mybanner" android:layout_width="match_parent" android:layout_height="150dp"></com.youth.banner.Banner> </LinearLayout>
第四步:(創(chuàng)建GlideImageLoader 圖片加載類)
public class GlideImageLoader extends ImageLoader { @Override public void displayImage(Context context, Object path, ImageView imageView) { Glide.with(context).load(path).into(imageView); } }
第五步:(在onCreate中加)
mbanner= (Banner) findViewById(R.id.mybanner); GetDate(mpath);
private void GetDate(String url){ OkHttp3Utils.getInstance().doGet(url, new GsonObjectCallback<HomeBean>() { @Override public void onUi(HomeBean homeBean) { for(int i=0; i<homeBean.getData().getAd1().size();i++){ String ad1s = homeBean.getData().getAd1().get(i).getImage(); mlist.add(ad1s); } //設(shè)置圖片加載器 mbanner.setImageLoader(new GlideImageLoader()); mbanner.setImages(mlist); mbanner.start(); } @Override public void onFailed(Call call, IOException e) { } }); }
最后提醒:網(wǎng)絡(luò)數(shù)據(jù)接口您自己供應(yīng)。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android實(shí)現(xiàn)輪播圖片展示效果
- Android實(shí)現(xiàn)炫酷輪播圖效果
- Android使用viewpager實(shí)現(xiàn)自動(dòng)無(wú)限輪播圖
- Android實(shí)現(xiàn)ViewPage輪播圖效果
- Android ViewPager實(shí)現(xiàn)輪播圖效果
- Android開(kāi)發(fā)實(shí)現(xiàn)的自動(dòng)換圖片、輪播圖效果示例
- Android如何使用RecyclerView打造首頁(yè)輪播圖
- 簡(jiǎn)單實(shí)現(xiàn)android輪播圖
- Android自定義控件實(shí)現(xiàn)優(yōu)雅的廣告輪播圖
- Android自定義輪播圖效果
相關(guān)文章
Android音頻系統(tǒng)AudioTrack使用方法詳解
這篇文章主要為大家詳細(xì)介紹了Android音頻系統(tǒng)AudioTrack的使用方法,如何使用AudioTrack進(jìn)行音頻播放,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07Kotlin中的惰性操作容器Sequence序列使用原理詳解
這篇文章主要為大家介紹了Kotlin中的惰性操作容器Sequence序列使用原理詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-09-09Android 判斷網(wǎng)絡(luò)狀態(tài)及開(kāi)啟網(wǎng)路
這篇文章主要介紹了Android 判斷網(wǎng)絡(luò)狀態(tài)及開(kāi)啟網(wǎng)路的相關(guān)資料,在開(kāi)發(fā)網(wǎng)路狀態(tài)的時(shí)候需要先判斷是否開(kāi)啟之后在提示用戶進(jìn)行開(kāi)啟操作,需要的朋友可以參考下2017-08-08Android?Framework如何實(shí)現(xiàn)Binder
這篇文章主要介紹了Android?Framework如何實(shí)現(xiàn)Binder,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-09-09淺談Android Studio 3.0 工具新特性的使用 Android Profiler 、Device File
這篇文章主要介紹了淺談Android Studio 3.0 工具新特性的使用 Android Profiler 、Device File Explorer的相關(guān)資料,需要的朋友可以參考下2017-11-11Android帶刷新時(shí)間顯示的PullToRefresh上下拉刷新
這篇文章主要為大家詳細(xì)介紹了Android帶刷新時(shí)間顯示的PullToRefresh上下拉刷新,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-12-12