你懂得,嘿嘿嘿

你懂得,嘿嘿嘿进入AppViewPager实现引导页<?xmlversion="1.0"encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"

进入AppViewPager实现引导页

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    >
    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager_ydy"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></android.support.v4.view.ViewPager>
    <Button
        android:id="@+id/button_ydy"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="650dp"
        android:text="点击跳过" />
</RelativeLayout>

java代码

package com.example.kanghuwei_exam;

import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.example.kanghuwei_exam.adapter.MyYdYadapter;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {
    private ViewPager viewpager_ydy;
    private Button button_ydy;
    private ArrayList<ImageView>list = new ArrayList<>();
    private MyYdYadapter yadapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        viewpager_ydy = findViewById(R.id.viewpager_ydy);
        button_ydy = findViewById(R.id.button_ydy);

        button_ydy.setVisibility(View.GONE);
        int arr[] ={R.drawable.a2,R.drawable.a3,R.drawable.a5,R.drawable.a6};
        for (int i=0;i<arr.length; i++){
            ImageView imageView = new ImageView(MainActivity.this);
            imageView.setImageResource(arr[i]);
            list.add(imageView);
        }
        yadapter = new MyYdYadapter(list);
        viewpager_ydy.setAdapter(yadapter);
        button_ydy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,TwoActivity.class);
                startActivity(intent);
            }
        });

        viewpager_ydy.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int i, float v, int i1) {

            }

            @Override
            public void onPageSelected(int i) {

                if (i==list.size()-1){
                    button_ydy.setVisibility(View.VISIBLE);
                }else {
                    button_ydy.setVisibility(View.INVISIBLE);
                }
            }

            @Override
            public void onPageScrollStateChanged(int i) {

            }
        });
    }
}

进入第二个页面 Fragment+ViewPager实现页面切换以及侧拉效果

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/draw"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".TwoActivity"
    >
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <FrameLayout
            android:id="@+id/fragment"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="9"
            ></FrameLayout>
        <RadioGroup
            android:id="@+id/radiogroup"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:orientation="horizontal"
            >
            <RadioButton
                android:id="@+id/radiobutton1"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:text="首页"
                android:gravity="center"
                android:button="@null"
                android:layout_weight="1"
                android:drawableTop="@drawable/selector_button1"
                />
            <RadioButton
                android:id="@+id/radiobutton2"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:text="联系人"
                android:gravity="center"
                android:button="@null"
                android:layout_weight="1"
                android:drawableTop="@drawable/selector_button2"
                />
            <RadioButton
                android:id="@+id/radiobutton3"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:text="动态"
                android:gravity="center"
                android:button="@null"
                android:layout_weight="1"
                android:drawableTop="@drawable/selector_button3"
                />
        </RadioGroup>
    </LinearLayout>
    <LinearLayout
        android:background="#cc00cc"
        android:layout_width="300dp"
        android:layout_height="match_parent"
        android:layout_gravity="left"
        >
        <ImageView
            android:src="@drawable/a6"
            android:layout_gravity="left"
            android:layout_width="400dp"
            android:layout_height="wrap_content" />
        <TextView
            android:gravity="center"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="99"
            />
    </LinearLayout>

</android.support.v4.widget.DrawerLayout>

java代码

package com.example.kanghuwei_exam;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.RadioGroup;
import android.widget.Toast;

import com.example.kanghuwei_exam.fragment.Frag_01;
import com.example.kanghuwei_exam.fragment.Frag_02;
import com.example.kanghuwei_exam.fragment.Frag_03;

import java.util.ArrayList;
/* *
 * @User: 橘子丶
 * @Data: 2018/12/20 14:45
 * @Params:
 * @File_name: TwoActivity.java
 * */
public class TwoActivity extends AppCompatActivity {
    private ArrayList<Fragment>list = new ArrayList<>();
    private RadioGroup radiogroup;
    private FragmentManager manager;
    private FragmentTransaction transaction;
    private DrawerLayout draw;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_two);
        radiogroup = findViewById(R.id.radiogroup);
        draw = findViewById(R.id.draw);
        manager = getSupportFragmentManager();
        transaction = manager.beginTransaction();
        final Frag_01 frag_01 = new Frag_01();
        final Frag_02 frag_02 = new Frag_02();
        final Frag_03 frag_03 = new Frag_03();
        transaction.add(R.id.fragment,frag_01,"Frag_01");
        transaction.add(R.id.fragment,frag_02);
        transaction.add(R.id.fragment,frag_03);
        transaction.show(frag_01).hide(frag_02).hide(frag_03);
        transaction.commit();
        radiogroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                transaction = manager.beginTransaction();
                switch (checkedId){
                    case R.id.radiobutton1:
                        transaction.show(frag_01).hide(frag_02).hide(frag_03);
                        break;
                    case R.id.radiobutton2:
                        transaction.show(frag_02).hide(frag_01).hide(frag_03);
                        break;
                    case R.id.radiobutton3:
                        transaction.show(frag_03).hide(frag_02).hide(frag_01);
                        break;
                }
                transaction.commit();
            }
        });
        draw.addDrawerListener(new DrawerLayout.DrawerListener() {
            @Override
            public void onDrawerSlide(@NonNull View view, float v) {

            }

            @Override
            public void onDrawerOpened(@NonNull View view) {
                Toast.makeText(TwoActivity.this,"啊啊啊,我被打开啦!",Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onDrawerClosed(@NonNull View view) {
                Toast.makeText(TwoActivity.this,"啊啊啊,我被关闭啦!",Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onDrawerStateChanged(int i) {

            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        Fragment frag_01 = manager.findFragmentByTag("Frag_01");
        frag_01.onActivityResult(requestCode, resultCode, data);
    }
}

Frag_01 频道管理+ViewPager

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >
    <LinearLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:orientation="horizontal"
        >
        <android.support.design.widget.TabLayout
            android:id="@+id/tb"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="8"
            >
        </android.support.design.widget.TabLayout>
        <Button
            android:id="@+id/btn"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:text="+"
            />
    </LinearLayout>
    <android.support.v4.view.ViewPager
        android:id="@+id/vp"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="9"
        ></android.support.v4.view.ViewPager>
</LinearLayout>

java代码

package com.example.kanghuwei_exam.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.andy.library.ChannelActivity;
import com.andy.library.ChannelBean;
import com.example.kanghuwei_exam.Mfragment.MFragment1;
import com.example.kanghuwei_exam.Mfragment.MFragment2;
import com.example.kanghuwei_exam.Mfragment.MFragment3;
import com.example.kanghuwei_exam.R;
import com.example.kanghuwei_exam.adapter.MyPagerAdapter;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.ArrayList;

/**
 * 作者:${橘子丶} on 2018/12/20 14:48
 * <p>
 * 邮箱:1242918242@qq.com
 */
public class Frag_01 extends Fragment {
    private TabLayout tb;
    private ViewPager vp;
    private Button btn;
    private ArrayList<Fragment> fragmentlist = new ArrayList<>();
    private ArrayList<ChannelBean> channelBeanlist = new ArrayList<>();
    private MyPagerAdapter madapter;
    private View view;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.frag_01, container, false);
        initView();
        initData();
        return view;
    }

    private void initView() {
        tb = view.findViewById(R.id.tb);
        vp = view.findViewById(R.id.vp);
        btn = view.findViewById(R.id.btn);


        madapter = new MyPagerAdapter(getChildFragmentManager(), fragmentlist, channelBeanlist, getActivity());
        vp.setAdapter(madapter);
        //
        tb.setupWithViewPager(vp);

        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ChannelActivity.startChannelActivity((AppCompatActivity) getActivity(), channelBeanlist);
            }
        });
    }

    private void initData() {
        channelBeanlist.add(new ChannelBean("热点", true));
        channelBeanlist.add(new ChannelBean("北京", true));
        channelBeanlist.add(new ChannelBean("房价", true));
        channelBeanlist.add(new ChannelBean("娱乐", false));
        channelBeanlist.add(new ChannelBean("旅游", false));
        for (int i = 0; i < channelBeanlist.size(); i++) {
            if (channelBeanlist.get(i).isSelect()) {
                tb.addTab(tb.newTab().setText(channelBeanlist.get(i).getName()));
                if (i == 0) {
                    fragmentlist.add(new MFragment1());
                } else if (i == 1) {
                    fragmentlist.add(new MFragment2());
                } else {
                    fragmentlist.add(new MFragment3());
                }
            }
        }
        madapter.notifyDataSetChanged();
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        String stringExtra = data.getStringExtra(ChannelActivity.RESULT_JSON_KEY);
        Gson gson = new Gson();
        Type type = new TypeToken<ArrayList<ChannelBean>>() {
        }.getType();
        channelBeanlist = gson.fromJson(stringExtra, type);
        tb.removeAllTabs();
        fragmentlist.clear();
        for (int i = 0; i < channelBeanlist.size(); i++) {
            if (channelBeanlist.get(i).isSelect()) {
                tb.addTab(tb.newTab().setText(channelBeanlist.get(i).getName()));
                if (i == 0) {
                    fragmentlist.add(new MFragment1());
                } else if (i == 1) {
                    fragmentlist.add(new MFragment2());
                } else {
                    fragmentlist.add(new MFragment3());
                }
            }
        }
        madapter.notifyDataSetChanged();
    }
}

Frag_01频道管理第一个页面 banner+PullToRefreshListView 实现无限轮播+上拉加载下拉刷新

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.youth.banner.Banner
        android:id="@+id/banner"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3"></com.youth.banner.Banner>

    <com.handmark.pulltorefresh.library.PullToRefreshListView
        android:id="@+id/plv"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="7"></com.handmark.pulltorefresh.library.PullToRefreshListView>
</LinearLayout>

java代码

package com.example.kanghuwei_exam.Mfragment;

import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;

import com.example.kanghuwei_exam.NetUtils;
import com.example.kanghuwei_exam.R;
import com.example.kanghuwei_exam.adapter.MyPLVAdapter;
import com.example.kanghuwei_exam.bean.ListBean;
import com.google.gson.Gson;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.youth.banner.Banner;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 作者:${橘子丶} on 2018/12/20 15:27
 * <p>
 * 邮箱:1242918242@qq.com
 */
public class MFragment1 extends Fragment {
    private String url = "http://api.tianapi.com/meinv/?key=3304a8bc9414f97e30928b80163cf098&num=90";
    private   String[] urls = {"https://img-my.csdn.net/uploads/201407/26/1406383265_8550.jpg",
            "http://lh4.googleusercontent.com/--dq8niRp7W4/URquVgmXvgI/AAAAAAAAAbs/-gnuLQfNnBA/s160-c/A%252520Song%252520of%252520Ice%252520and%252520Fire.jpg",
            "http://lh5.googleusercontent.com/-7qZeDtRKFKc/URquWZT1gOI/AAAAAAAAAbs/hqWgteyNXsg/s160-c/Another%252520Rockaway%252520Sunset.jpg",
            "https://img-my.csdn.net/uploads/201407/26/1406383265_8550.jpg",
            "http://lh6.googleusercontent.com/-8HO-4vIFnlw/URquZnsFgtI/AAAAAAAAAbs/WT8jViTF7vw/s160-c/Antelope%252520Hallway.jpg",
            "http://lh4.googleusercontent.com/-WIuWgVcU3Qw/URqubRVcj4I/AAAAAAAAAbs/YvbwgGjwdIQ/s160-c/Antelope%252520Walls.jpg"};
    private Banner banner;
    private PullToRefreshListView plv;
    private ArrayList<ListBean.NewslistBean> list = new ArrayList<ListBean.NewslistBean>();
    private ImageLoader imageLoaderstance;
    private MyPLVAdapter plvadapter;
    private  int page;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.ffrag_01,container,false);
        banner = view.findViewById(R.id.banner);
        plv = view.findViewById(R.id.plv);
        imageLoaderstance = ImageLoader.getInstance();

        new MAsyncTask().execute(url);

        plvadapter = new MyPLVAdapter(list,imageLoaderstance,getActivity());
        plv.setAdapter(plvadapter);
        plv.setMode(PullToRefreshBase.Mode.BOTH);
        plv.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
            @Override
            public void onPullDownToRefresh(PullToRefreshBase<ListView> pullToRefreshBase) {
                page=0;
                list.clear();
                new MAsyncTask().execute(url+page);
            }

            @Override
            public void onPullUpToRefresh(PullToRefreshBase<ListView> pullToRefreshBase) {
                page++;
                new MAsyncTask().execute(url+page);
            }
        });

        banner.setImageLoader(new com.youth.banner.loader.ImageLoader() {
            @Override
            public void displayImage(Context context, Object path, ImageView imageView) {
                imageLoaderstance.displayImage((String) path,imageView);
            }
        });
        banner.setImages(Arrays.asList(urls));
        banner.start();
        return view;
    }
    public class MAsyncTask extends AsyncTask<String,Void,String>{

        @Override
        protected String doInBackground(String... strings) {
            return NetUtils.getJson(strings[0]);
        }

        @Override
        protected void onPostExecute(String s) {
            super.onPostExecute(s);
            Gson gson = new Gson();
            ListBean listBean = gson.fromJson(s, ListBean.class);
            List<ListBean.NewslistBean> newslist = listBean.getNewslist();
            list.addAll(newslist);
            plvadapter.notifyDataSetChanged();
            plv.onRefreshComplete();
        }
    }
}

Frag_01频道管理第二个页面 XListView

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.bwie.xlistviewlibrary.view.XListView
        android:id="@+id/xlv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />
</LinearLayout>

java代码

package com.example.kanghuwei_exam.Mfragment;

import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bwie.xlistviewlibrary.view.XListView;
import com.example.kanghuwei_exam.NetUtils;
import com.example.kanghuwei_exam.R;
import com.example.kanghuwei_exam.adapter.MyXLVapapter;
import com.example.kanghuwei_exam.bean.JsonBean;
import com.google.gson.Gson;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.ArrayList;
import java.util.List;

/**
 * 作者:${橘子丶} on 2018/12/20 15:27
 * <p>
 * 邮箱:1242918242@qq.com
 */
public class MFragment2 extends Fragment {
    private String url = "https://www.apiopen.top/meituApi?page=1";
    private XListView xlv;
    private ArrayList<JsonBean.DataBean> list = new ArrayList<>();
    private ImageLoader imageLoaderstance;
    private MyXLVapapter xlvadapter;
    private int page;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.ffrag_02, container, false);
        xlv = view.findViewById(R.id.xlv);
        imageLoaderstance = ImageLoader.getInstance();
        xlvadapter = new MyXLVapapter(list, getActivity(), imageLoaderstance);
        xlv.setAdapter(xlvadapter);
        new MAsyncTask().execute(url + page);
        xlv.setPullLoadEnable(true);
        xlv.setPullRefreshEnable(true);
        xlv.setXListViewListener(new XListView.IXListViewListener() {
            @Override
            public void onRefresh() {
                page = 0;
                list.clear();
                new MAsyncTask().execute(url + page);
            }

            @Override
            public void onLoadMore() {
                page++;
                new MAsyncTask().execute(url + page);
            }
        });
        return view;
    }

    public class MAsyncTask extends AsyncTask<String, Void, String> {

        @Override
        protected String doInBackground(String... strings) {
            return NetUtils.getJson(strings[0]);
        }

        @Override
        protected void onPostExecute(String s) {
            super.onPostExecute(s);
            Gson gson = new Gson();
            JsonBean jsonBean = gson.fromJson(s, JsonBean.class);
            List<JsonBean.DataBean> data = jsonBean.getData();
            list.addAll(data);
            xlvadapter.notifyDataSetChanged();
            uicomple();
        }
    }
    public void uicomple() {
        xlv.setRefreshTime("--刚刚--");
        xlv.stopLoadMore();
        xlv.stopRefresh();
    }
}

ImageLoader

package com.example.kanghuwei_exam;
import android.app.Application;
import android.os.Environment;

import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import java.io.File;

public class MApp extends Application{
    File cacheFile= new File(Environment.getExternalStorageDirectory()+"/"+"imgages");
    @Override
    public void onCreate() {
        super.onCreate();

        ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this)
        .diskCache(new UnlimitedDiskCache(cacheFile))//自定义缓存目录
        .build();
        ImageLoader.getInstance().init(configuration);
    }
}
package com.example.kanghuwei_exam;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
/**
 * 作者:${橘子丶} on 2018/12/20 11:21
 * <p>
 * 邮箱:1242918242@qq.com
 */
public class ImageLoaderUtils_circle {
    public static DisplayImageOptions getDisplayImageOption() {
        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .showImageOnLoading(R.drawable.a6) //设置图片在下载期间显示的图片
                .showImageForEmptyUri(R.drawable.btn_back)//设置图片Uri为空或是错误的时候显示的图片
                .showImageOnFail(R.mipmap.ic_launcher)  //设置图片加载/解码过程中错误时候显示的图片
               /* .cacheInMemory(true)//设置下载的图片是否缓存在内存中
                .cacheOnDisk(true)
                .considerExifParams(true)  //是否考虑JPEG图像EXIF参数(旋转,翻转)
                .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)//设置图片以如何的编码方式显示
                .bitmapConfig(Bitmap.Config.RGB_565)//设置图片的解码类型//*/
                .displayer(new RoundedBitmapDisplayer(100))//是否设置为圆角,弧度为多少
                .displayer(new FadeInBitmapDisplayer(100))//是否图片加载好后渐入的动画时间
                .build();//构建完成
        return options;
    }
}

工具类

package com.example.kanghuwei_exam;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class NetUtils {
    public static String getJson(String string) {

        try {
            URL url = new URL(string);
            HttpURLConnection urlConnection =(HttpURLConnection) url.openConnection();
            int responseCode = urlConnection.getResponseCode();
            if(responseCode==200){
                InputStream inputStream = urlConnection.getInputStream();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
                String temp = "";
                StringBuilder stringBuilder = new StringBuilder();
                while((temp=bufferedReader.readLine())!=null){
                    stringBuilder.append(temp);
                }
                return stringBuilder.toString();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }
}

引导页适配器

package com.example.kanghuwei_exam.adapter;

import android.support.annotation.NonNull;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.ArrayList;

/**
 * 作者:${橘子丶} on 2018/12/20 14:07
 * <p>
 * 邮箱:1242918242@qq.com
 */
public class MyYdYadapter extends PagerAdapter {
    private ArrayList<ImageView> list;

    public MyYdYadapter(ArrayList<ImageView> list) {
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object o) {
        return view == o;
    }

    @NonNull
    @Override
    public Object instantiateItem(@NonNull ViewGroup container, int position) {
        ImageView imageView = list.get(position);
        container.addView(imageView);
        return imageView;
    }

    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
        container.removeView((View)object);
    }
}

频道管理适配器

package com.example.kanghuwei_exam.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.andy.library.ChannelBean;

import java.util.ArrayList;

/**
 * 作者:${橘子丶} on 2018/12/20 15:19
 * <p>
 * 邮箱:1242918242@qq.com
 */
public class MyPagerAdapter extends FragmentPagerAdapter {
    private ArrayList<Fragment> fragmentlist = new ArrayList<>();
    private ArrayList<ChannelBean> channelBeanlist = new ArrayList<>();
    private Context context;

    public MyPagerAdapter(FragmentManager fm, ArrayList<Fragment> fragmentlist, ArrayList<ChannelBean> channelBeanlist, Context context) {
        super(fm);
        this.fragmentlist = fragmentlist;
        this.channelBeanlist = channelBeanlist;
        this.context = context;
    }

    public MyPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int i) {
        return fragmentlist.get(i);
    }

    @Override
    public int getCount() {
        return fragmentlist.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return channelBeanlist.get(position).getName();
    }
}

PullToReFresh适配器

package com.example.kanghuwei_exam.adapter;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.kanghuwei_exam.ImageLoaderUtils_circle;
import com.example.kanghuwei_exam.R;
import com.example.kanghuwei_exam.bean.ListBean;
import com.nostra13.universalimageloader.core.ImageLoader;
import java.util.ArrayList;

/**
 * 作者:${橘子丶} on 2018/12/20 16:23
 * <p>
 * 邮箱:1242918242@qq.com
 */
public class MyPLVAdapter extends BaseAdapter {
    private ArrayList<ListBean.NewslistBean>list;
    private ImageLoader imageLoaderstacnce;
    private Context context;

    public MyPLVAdapter(ArrayList<ListBean.NewslistBean> list, ImageLoader imageLoaderstacnce, Context context) {
        this.list = list;
        this.imageLoaderstacnce = imageLoaderstacnce;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null){
            convertView = View.inflate(context,R.layout.plv_item,null);
            holder = new ViewHolder();
            holder.iv1 = convertView.findViewById(R.id.iv1);
            holder.tv1 = convertView.findViewById(R.id.tv1);
            holder.tv2 = convertView.findViewById(R.id.tv2);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.tv1.setText(list.get(position).getTitle());
        holder.tv2.setText(list.get(position).getCtime());
        imageLoaderstacnce.displayImage(list.get(position).getPicUrl(),holder.iv1,ImageLoaderUtils_circle.getDisplayImageOption());
        return convertView;
    }
    class ViewHolder{
        TextView tv1,tv2;
        ImageView iv1;
    }
}

XListView多条目适配器

package com.example.kanghuwei20181219.adapter;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.kanghuwei20181219.ImageLoaderUtils_circle;
import com.example.kanghuwei20181219.R;
import com.example.kanghuwei20181219.bean.ListBean;
import com.nostra13.universalimageloader.core.ImageLoader;
import java.util.ArrayList;
import java.util.List;

/**
 * 作者:${橘子丶} on 2018/12/20 10:46
 * <p>
 * 邮箱:1242918242@qq.com
 */
public class MyXVadapter extends BaseAdapter {
    private List<ListBean.NewslistBean>list = new ArrayList<>();
    private Context context;
    private ImageLoader imageLoaderstance;

    public MyXVadapter(List<ListBean.NewslistBean> list, Context context, ImageLoader imageLoaderstance) {
        this.list = list;
        this.context = context;
        this.imageLoaderstance = imageLoaderstance;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public int getViewTypeCount() {
        return 2;
    }

    @Override
    public int getItemViewType(int position) {
        if (position%2==0){
            return 0;
        }else {
            return 1;
        }
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        int itemViewType = getItemViewType(position);
        switch (itemViewType){
            case 0:
                ViewHolder0 holder0;
                if (convertView ==null){
                    convertView = View.inflate(context,R.layout.xlv_item_00,null);
                    holder0 = new ViewHolder0();
                    holder0.tv11 = convertView.findViewById(R.id.tv11);
                    holder0.tv22 = convertView.findViewById(R.id.tv22);
                    convertView.setTag(holder0);
                }else {
                    holder0 = (ViewHolder0) convertView.getTag();
                }
                holder0.tv11.setText(list.get(position).getTitle());
                holder0.tv22.setText(list.get(position).getCtime());
                break;
            case 1:
                ViewHolder1 holder1;
                if (convertView ==null){
                    convertView = View.inflate(context,R.layout.xlv_item_11,null);
                    holder1 = new ViewHolder1();
                    holder1.textview11 = convertView.findViewById(R.id.textview11);
                    holder1.textview22 = convertView.findViewById(R.id.textview11);
                    holder1.imageview11 = convertView.findViewById(R.id.imageview11);
                    convertView.setTag(holder1);
                }else {
                    holder1 = (ViewHolder1) convertView.getTag();
                }
                holder1.textview11.setText(list.get(position).getTitle());
                holder1.textview22.setText(list.get(position).getCtime());
                imageLoaderstance.displayImage(list.get(position).getPicUrl(),holder1.imageview11,ImageLoaderUtils_circle.getDisplayImageOption());
                break;
        }
        return convertView;
    }
class ViewHolder0{
        TextView tv11,tv22;
}
class ViewHolder1{
        TextView textview11,textview22;
        ImageView imageview11;
}
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/36361.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注