Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use Android banner

Shulou Source: shulou.com Published: 2022-06-02 16:44:20 10月01日 Update

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)

Tags: Indication indicator fillet effect direction color width method position cycle time life monitoring properties layout manual data file loop between Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info OPPO Reno Xiaomi Redmi MySQL