Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Android banner

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to use Android banner". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use Android banner.

Effect picture:

Add dependency implementation 'com.youth.banner:banner:2.1.0' add permissions to your AndroidManifest.xml layout file logic code package com.hnucm.xiaotang;import android.os.Bundle;import androidx.fragment.app.Fragment;import android.util.Log;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import com.bumptech.glide.Glide;import com.bumptech.glide.load.resource.bitmap.RoundedCorners;import com.bumptech.glide.request.RequestOptions Import com.youth.banner.Banner;import com.youth.banner.adapter.BannerImageAdapter;import com.youth.banner.holder.BannerImageHolder;import com.youth.banner.indicator.CircleIndicator;import com.youth.banner.listener.OnBannerListener;import org.json.JSONArray;import org.json.JSONException;import org.xutils.common.Callback;import org.xutils.http.RequestParams;import org.xutils.x;import java.util.ArrayList;import java.util.List Public class ShouYeFragment extends Fragment implements OnBannerListener {@ Override public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {View inflate = inflater.inflate (R.layout.fragment_shou_ye, container, false); Banner banner = inflate.findViewById (R.id.banner); List imgList = new ArrayList (); x.Ext.init (getActivity (). GetApplication ()); x.Ext.setDebug (BuildConfig.DEBUG) / / whether to output debug logs. Enabling debug will affect performance. X.view () .inject (getActivity ()); / / if you don't use view annotations, you don't need imgList.add ("https://cdn.jsdelivr.net/gh/Yqifei/Blog-Image@master/20211026/image.6719h9mvs700.png"); imgList.add (" https://cdn.jsdelivr.net/gh/Yqifei/Blog-Image@master/20211031/800-(11).2txrpbqztva0.jpg");) " ImgList.add ("https://cdn.jsdelivr.net/gh/Yqifei/Blog-Image@master/20211031/800-(5).5s6zwxy19v40.jpg"); imgList.add (" https://cdn.jsdelivr.net/gh/Yqifei/Blog-Image@master/20211031/800-(10).24p8puxcmqbk.jpg"); imgList.add ("https://cdn.jsdelivr.net/gh/Yqifei/Blog-Image@master/20211031/800-(14).pizaxijh634.jpg");") RequestParams params = new RequestParams ("https://www.fastmock.site/mock/08392ee207964eb010bf22b157103494/androidJavaEE/banner"); x.http (). Get (params, new Callback.CommonCallback () {@ Override public void onSuccess (String result) {try {JSONArray jsonArray = new JSONArray (result); for (int iTuno)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report