侧拉加无限轮播

main
<android.support.v4.widget.DrawerLayout
    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:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.hello.myweizuoming20171021.MainActivity">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        >
        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/frame_layout"
            android:layout_above="@+id/radio_group"
            >

        </FrameLayout>
        <RadioGroup
            android:id="@+id/radio_group"
            android:layout_alignParentBottom="true"
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            >
            <RadioButton
                android:id="@+id/rb1"
                android:button="@null"

                android:gravity="center"
                android:clickable="true"
                android:padding="10dp"
                android:background="@drawable/radio_selector"
                android:layout_width="wrap_content"
                android:layout_weight="1"
                android:layout_height="match_parent" />
            <RadioButton
                android:id="@+id/rb2"
                android:button="@null"

                android:gravity="center"
                android:clickable="true"
                android:padding="10dp"
                android:background="@drawable/radio_selector2"
                android:layout_width="wrap_content"
                android:layout_weight="1"
                android:layout_height="match_parent" />
            <RadioButton
                android:id="@+id/rb3"
                android:button="@null"

                android:gravity="center"
                android:clickable="true"
                android:padding="10dp"
                android:background="@drawable/xlistview_arrow"
                android:layout_width="wrap_content"
                android:layout_weight="1"
                android:layout_height="match_parent" />
            <RadioButton
                android:id="@+id/rb4"
                android:button="@null"

                android:gravity="center"
                android:clickable="true"
                android:padding="10dp"
                android:background="@drawable/radio_selector3"
                android:layout_width="wrap_content"
                android:layout_weight="1"
                android:layout_height="match_parent" />
        </RadioGroup>
    </RelativeLayout>
    <RelativeLayout
        android:background="#ffffff"
        android:id="@+id/drawer_relative"
        android:layout_gravity="left"
        android:layout_width="200dp"
        android:layout_height="match_parent">

        <ImageView
            android:id="@+id/image_touxiang"
            android:layout_centerHorizontal="true"
            android:layout_margin="10dp"
            android:src="@mipmap/ic_launcher"
            android:layout_width="80dp"
            android:layout_height="80dp" />



    </RelativeLayout>


</android.support.v4.widget.DrawerLayout>
+++++++++++++++++++++++++++++++++++++++++++++++++++++
faxian
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:background="#f89"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

</LinearLayout>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
home
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"

    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <android.support.design.widget.TabLayout
        android:id="@+id/tab"
        app:tabGravity="center"
        app:tabIndicatorColor="@color/colorAccent"
        app:tabMode="scrollable"
        app:tabSelectedTextColor="@color/colorPrimaryDark"
        app:tabTextColor="@color/colorPrimary"
        android:layout_width="match_parent"
        android:layout_height="40dp">

    </android.support.design.widget.TabLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >
    </android.support.v4.view.ViewPager>
</LinearLayout>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
tuijian
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <com.handmark.pulltorefresh.library.PullToRefreshScrollView
        xmlns:ptr="http://schemas.android.com/apk/res-auto"
        android:id="@+id/refresh_scroll_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        ptr:ptrAnimationStyle="flip"
        ptr:ptrDrawable="@drawable/default_ptr_flip"
        ptr:ptrHeaderBackground="#383838"
        ptr:ptrHeaderTextColor="#FFFFFF">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.v4.view.ViewPager
                android:id="@+id/image_view_pager"
                android:layout_width="match_parent"
                android:layout_height="200dp">

            </android.support.v4.view.ViewPager>

            <com.example.hello.myweizuoming20171021.util.MyListView
                android:id="@+id/scroll_list_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

            </com.example.hello.myweizuoming20171021.util.MyListView>
        </LinearLayout>
    </com.handmark.pulltorefresh.library.PullToRefreshScrollView>
</LinearLayout>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
item_img_layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:padding="10dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
        android:id="@+id/text_title"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content" />

    <ImageView
        android:id="@+id/image_view"
        android:layout_width="100dp"
        android:layout_height="100dp" />
</LinearLayout>

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
item_text_layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:padding="10dp" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/text_title" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" /></LinearLayout>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
kecheng
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:background="#a76"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

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

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

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

</LinearLayout>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MainActivity
public class MainActivity extends AppCompatActivity {
    private DrawerLayout dl;

    private RelativeLayout rl;
    private List<DataDataBean.ResultsBean> list = new ArrayList<>();

    private MyAdapter myAdapter;
    private int page_num=1;
    private RadioGroup radioGroup;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        radioGroup = (RadioGroup) findViewById(R.id.radio_group);
        dl = (DrawerLayout) findViewById(R.id.drawer_layout);
        //主内容区域的布局

        //抽屉布局
        rl = (RelativeLayout) findViewById(R.id.drawer_relative);
        ImageView imageView=(ImageView)findViewById(R.id.image_touxiang) ;
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                dl.closeDrawer(rl);
            }
        });

        //设置点击事件

        //抽屉的监听事件
        dl.setDrawerListener(new DrawerLayout.DrawerListener() {

            /**
             *
             * @param drawerView
             * @param slideOffset 表示的抽屉拖出来的宽度,,像素值
             */
            @Override
            public void onDrawerSlide(View drawerView, float slideOffset) {

            }

            /**
             * 抽屉打开了
             * @param drawerView
             */
            @Override
            public void onDrawerOpened(View drawerView) {

            }

            /**
             * 抽屉关闭
             * @param drawerView
             */
            @Override
            public void onDrawerClosed(View drawerView) {

            }

            /**
             * 抽屉的状态改变
             *
             * idle -- 表示与导航视图没有交互,静止
             dragging -- 表示目前有与导航视图的交互,拖拽的状态
             settling -- 表示有与导航视图的交互,并且导航视图正在关闭或打开
             * @param newState
             */
            @Override
            public void onDrawerStateChanged(int newState) {
                Log.i("zhaungtai---",newState+"---");
            }
        });
        //默认显示
        getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout,new Fragmenthome()).commit();

        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                switch (i){
                    case R.id.rb1:
                        getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout,new Fragmenthome()).commit();
                        break;
                    case R.id.rb2:
                        getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout,new Fragmentxiangfa()).commit();
                        break;
                    case R.id.rb3:
                        getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout,new Fragmentxiazai()).commit();
                        break;
                    case R.id.rb4:
                        getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout,new Fragmentuser()).commit();
                        break;
                    default:
                        break;
                }
            }
        });
    }
    }

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

public class StringUtil {
    public static String streamToString(InputStream inputStream, String charset) {
        try {
            InputStreamReader inputStreamReader = new InputStreamReader(inputStream,charset);

            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
            String s = null;
            StringBuilder builder = new StringBuilder();
            while ((s = bufferedReader.readLine()) != null){
                builder.append(s);
            }

            bufferedReader.close();
            return builder.toString();

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

        return  null;
    }
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
public class NetWorkUtil {
    /**
     * 这个方法是判断网络状态是否可用的
     * @param context
     * @return
     */
    public static boolean isConn(Context context){
        boolean bisConnFlag=false;
        //1.获取网络连接的管理对象
        ConnectivityManager conManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
        //2.通过管理者对象拿到网络的信息
        NetworkInfo network = conManager.getActiveNetworkInfo();
        if(network!=null){
            //3.网络状态是否可用的返回值
            bisConnFlag=network.isAvailable();
        }
        return bisConnFlag;
    }

    /**
     * 如果没有网络 弹出dialog对话框,,,是否进入设置网络的页面
     * @param context
     */
    public static void showNoNetWorkDlg(final Context context) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setIcon(R.mipmap.ic_launcher)         //
                .setTitle("警告")            //
                .setMessage("当前无网络,是否去设置?").setPositiveButton("设置", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                // 跳转到系统的网络设置界面
                Intent intent = null;
                // 先判断当前系统版本
                if(android.os.Build.VERSION.SDK_INT > 10){  // 3.0以上
                    intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS);
                }else{
                    intent = new Intent();
                    intent.setClassName("com.android.settings", "com.android.settings.WirelessSettings");
                }
                context.startActivity(intent);

            }
        }).setNegativeButton("取消", null).show();
    }
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
public class NetDataUtil {
    public static void getData(final String path, Context context, final JsonCallBack callBack){

        if (NetWorkUtil.isConn(context)){

            AsyncTask<Void, Void, String> asyncTask = new AsyncTask<Void, Void, String>() {
                @Override
                protected String doInBackground(Void... voids) {

                    try {
                        URL url = new URL(path);

                        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                        connection.setRequestMethod("GET");
                        connection.setReadTimeout(5000);
                        connection.setConnectTimeout(5000);

                        int responseCode = connection.getResponseCode();
                        if (responseCode == 200){
                            Log.d("TAG","++++++++++++++++++++++++++++"+responseCode);
                            InputStream inputStream = connection.getInputStream();

                            String json = StringUtil.streamToString(inputStream,"utf-8");

                            return json;
                        }

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

                    return null;
                }

                @Override
                protected void onPostExecute(String s) {
                    //通过接口把json格式的字符串传递回去....
                    callBack.getJsonString(s);
                }
            };

            asyncTask.execute();

        }else {
            NetWorkUtil.showNoNetWorkDlg(context);
        }

    }

}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
public class MyListView extends ListView {
    public MyListView(Context context) {
        super(context);
    }

    public MyListView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyListView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    /**
     * 重新计算高度
     * @param widthMeasureSpec
     * @param heightMeasureSpec
     */
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, expandSpec);
    }

   /* @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        super.onLayout(changed, l, t, r, b);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
    }*/
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++
public class ImageLoaderUtil {
    public static void init(Context context){
        File cacheDir = StorageUtils.getCacheDirectory(context);
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)

                .threadPoolSize(3) // default  线程池内加载的数量
                .threadPriority(Thread.NORM_PRIORITY - 2) // default 设置当前线程的优先级
                .tasksProcessingOrder(QueueProcessingType.FIFO) // default
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache(new LruMemoryCache(2 * 1024 * 1024)) //可以通过自己的内存缓存实现
                .memoryCacheSize(2 * 1024 * 1024)  // 内存缓存的最大值
                .memoryCacheSizePercentage(13) // default
                .diskCache(new UnlimitedDiskCache(cacheDir)) // default 可以自定义缓存路径
                .diskCacheSize(50 * 1024 * 1024) // 50 Mb sd卡(本地)缓存的最大值
                .diskCacheFileCount(100)  // 可以缓存的文件数量
                // default为使用HASHCODE对UIL进行加密命名, 还可以用MD5(new Md5FileNameGenerator())加密

                .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
                .writeDebugLogs() // 打印debug log
                .build(); //开始构建
        ImageLoader.getInstance().init(config);

    }
    public static DisplayImageOptions getDefaultOption(){
        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .showImageOnLoading(R.mipmap.ic_launcher) // 设置图片下载期间显示的图片
                .showImageForEmptyUri(R.mipmap.ic_launcher) // 设置图片Uri为空或是错误的时候显示的图片
                .showImageOnFail(R.mipmap.ic_launcher) // 设置图片加载或解码过程中发生错误显示的图片
                .resetViewBeforeLoading(true)  // default 设置图片在加载前是否重置、复位
                .delayBeforeLoading(1000)  // 下载前的延迟时间
                .cacheInMemory(true) // default  设置下载的图片是否缓存在内存中
                .cacheOnDisk(true) // default  设置下载的图片是否缓存在SD卡中

                .considerExifParams(true) // default
                .imageScaleType(ImageScaleType.EXACTLY_STRETCHED) // default 设置图片以如何的编码方式显示
                .bitmapConfig(Bitmap.Config.RGB_565) // default 设置图片的解码类型

                .displayer(new SimpleBitmapDisplayer()) // default  还可以设置圆角图片new RoundedBitmapDisplayer(20)

                .build();
        return options;
    }
    public static DisplayImageOptions getDefaultOptionyuan(){
        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .showImageOnLoading(R.mipmap.ic_launcher) // 设置图片下载期间显示的图片
                .showImageForEmptyUri(R.mipmap.ic_launcher) // 设置图片Uri为空或是错误的时候显示的图片
                .showImageOnFail(R.mipmap.ic_launcher) // 设置图片加载或解码过程中发生错误显示的图片
                .resetViewBeforeLoading(true)  // default 设置图片在加载前是否重置、复位
                .delayBeforeLoading(1000)  // 下载前的延迟时间
                .cacheInMemory(true) // default  设置下载的图片是否缓存在内存中
                .cacheOnDisk(true) // default  设置下载的图片是否缓存在SD卡中

                .considerExifParams(true) // default
                .imageScaleType(ImageScaleType.EXACTLY_STRETCHED) // default 设置图片以如何的编码方式显示
                .bitmapConfig(Bitmap.Config.RGB_565) // default 设置图片的解码类型

                .displayer(new CircleBitmapDisplayer()) // default  还可以设置圆角图片new RoundedBitmapDisplayer(20)

                .build();
        return options;
    }

    public static DisplayImageOptions gettupianyuanjiao(){
        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .showImageOnLoading(R.mipmap.ic_launcher) // 设置图片下载期间显示的图片
                .showImageForEmptyUri(R.mipmap.ic_launcher) // 设置图片Uri为空或是错误的时候显示的图片
                .showImageOnFail(R.mipmap.ic_launcher) // 设置图片加载或解码过程中发生错误显示的图片
                .resetViewBeforeLoading(true)  // default 设置图片在加载前是否重置、复位
                .delayBeforeLoading(1000)  // 下载前的延迟时间
                .cacheInMemory(true) // default  设置下载的图片是否缓存在内存中
                .cacheOnDisk(true) // default  设置下载的图片是否缓存在SD卡中

                .considerExifParams(true) // default
                .imageScaleType(ImageScaleType.EXACTLY_STRETCHED) // default 设置图片以如何的编码方式显示
                .bitmapConfig(Bitmap.Config.RGB_565) // default 设置图片的解码类型

                .displayer(new RoundedBitmapDisplayer(20)) // default  还可以设置圆角图片new RoundedBitmapDisplayer(20)

                .build();
        return options;

    }
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
public class MyAdapter extends BaseAdapter{
    Context context;
    List<DataDataBean.ResultsBean> list;
    public MyAdapter(Context context, List<DataDataBean.ResultsBean> list) {
        this.context = context;
        this.list = list;
    }
    private int TEXT_ONLY = 0;
    private int IMAGE_TEXT = 1;
    @Override
    public int getCount() {
        return list.size();
    }

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

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

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

    @Override
    public int getItemViewType(int position) {
        if (list.get(position).getImages() != null){
            return IMAGE_TEXT;
        }

        return TEXT_ONLY;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (getItemViewType(i) == TEXT_ONLY){
            TextHolder holder;
            if (view == null){
                view = View.inflate(context, R.layout.item_text_layout,null);
                holder = new TextHolder();

                holder.textView = view.findViewById(R.id.text_title);

                view.setTag(holder);

            }else {
                holder = (TextHolder) view.getTag();
            }

            holder.textView.setText(list.get(i).getDesc());

        }else if (getItemViewType(i)==IMAGE_TEXT){

            ImageHolder holder;
            if (view == null){
                view = View.inflate(context, R.layout.item_img_layout,null);
                holder = new ImageHolder();

                holder.textView = view.findViewById(R.id.text_title);
                holder.imageView = view.findViewById(R.id.image_view);

                view.setTag(holder);

            }else {
                holder = (ImageHolder) view.getTag();
            }


            //图片
            holder.textView.setText(list.get(i).getDesc());
            ImageLoader.getInstance().displayImage(list.get(i).getImages().get(0),holder.imageView, ImageLoaderUtil.gettupianyuanjiao());
        }

        return view;
    }

    private class TextHolder{
        TextView textView;
    }

    private class ImageHolder{
        TextView textView;
        ImageView imageView;
    }

}
++++++++++++++++++++++++++++++++++++++++++++++++++
public class ViewPagerAdapter extends PagerAdapter {
    Context context;
    List<String> imageUrlList;

    public ViewPagerAdapter(Context context, List<String> imageUrlList) {
        this.context = context;
        this.imageUrlList = imageUrlList;
    }

    @Override
    public int getCount() {
        return Integer.MAX_VALUE;
    }

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

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        //1.创建imageView...添加到容器中
        ImageView imageView = new ImageView(context);
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);

        //展示图片
        ImageLoader.getInstance().displayImage(imageUrlList.get(position%imageUrlList.size()),imageView, ImageLoaderUtil.getDefaultOptionyuan());

        //添加
        container.addView(imageView);

        //2.返回当前展示的imageView控件
        return imageView;
    }

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

public class BaseApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        ImageLoaderUtil.init(this);
    }
}
++++++++++++++++++++++++++++++++++++++++++++++++
public interface JsonCallBack {
    public void getJsonString(String json);
}
+++++++++++++++++++++++++++++++++++++++++++++++++
public class Fragmenthome extends Fragment {
    private TabLayout tabLayout;
    private ViewPager viewPager;
    private List<String> list;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.home_frame_view,container,false);
        tabLayout = view.findViewById(R.id.tab);
        viewPager =view.findViewById(R.id.view_pager);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        list = new ArrayList<>();
        list.add("推荐");
        list.add("课程");
        list.add("实战");
        list.add("职业路径");



        //设置适配器
        viewPager.setAdapter(new FragmentPagerAdapter(getChildFragmentManager()) {
            @Override
            public CharSequence getPageTitle(int position) {

                return list.get(position);
            }

            @Override
            public Fragment getItem(int position) {
                Fragment fragment = null;

                switch (position) {
                    case 0:
                        fragment = new Fragmenttuijian();
                        break;
                    case 1:
                        fragment = new Fragmentkecheng();
                        break;
                    case 2:
                        fragment = new Fragmentshizhan();
                        break;
                    case 3:
                        fragment = new Fragmentzhiyelujing();
                        break;


                    default:
                        break;
                }

                return fragment;
            }

            @Override
            public int getCount() {

                return list.size();
            }
        });

        //关联
        tabLayout.setupWithViewPager(viewPager);
    }


}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
public class Fragmentkecheng extends Fragment {
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.kecheng,container,false);

        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }
}
++++++++++++++++++++++++++++++++++++++++++++++++++
public class Fragmenttuijian extends Fragment {
    private PullToRefreshScrollView refreshScrollView;
    private ViewPager viewPager;
    private ListView listView;
    private List<DataDataBean.ResultsBean> list = new ArrayList<>();//记录当前展示的所有数据
    private int page_num = 1;
    private MyAdapter listViewAdapter;
    private ILoadingLayout startLabels;
    private List<String> imageUrlList;

    private Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == 0){
                //显示下一页....拿到当前页+1
                viewPager.setCurrentItem(viewPager.getCurrentItem() +1);

                //再次发送消息
                handler.sendEmptyMessageDelayed(0,2000);
            }
        }
    };

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.home_frame_view2, container, false);

        refreshScrollView = view.findViewById(R.id.refresh_scroll_view);
        viewPager = view.findViewById(R.id.image_view_pager);
        listView = view.findViewById(R.id.scroll_list_view);

        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        //失去焦点
        listView.setFocusable(false);


        //轮播图
        lunBoTu();

        //listView展示数据
        //1.获取网络数据,,,展示在listView上
        getDataFromNet();

        //2.设置刷新模式
        /*设置pullToRefreshListView的刷新模式,BOTH代表支持上拉和下拉,PULL_FROM_END代表上拉,PULL_FROM_START代表下拉 */
        refreshScrollView.setMode(PullToRefreshBase.Mode.BOTH);

        //3.通过getLoadingLayoutProxy 方法来指定上拉和下拉时显示的状态的区别(也就是设置向下拉的时候头部里面显示的文字)
        //此时这里设置的是下拉刷新的时候显示的文字,所以第一个设置true表示现在是刷新,第二个设置为false
        startLabels = refreshScrollView.getLoadingLayoutProxy(true, false);
        startLabels.setPullLabel("下拉刷新");
        startLabels.setRefreshingLabel("正在刷新...");
        startLabels.setReleaseLabel("放开刷新");

        ILoadingLayout endLabels = refreshScrollView.getLoadingLayoutProxy(false, true);
        endLabels.setPullLabel("上拉刷新");
        endLabels.setRefreshingLabel("正在载入...");
        endLabels.setReleaseLabel("放开刷新...");

        /**
         * 监听事件
         */
        refreshScrollView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ScrollView>() {
            @Override
            public void onPullDownToRefresh(PullToRefreshBase<ScrollView> refreshView) {
                getRefreshData();
            }

            @Override
            public void onPullUpToRefresh(PullToRefreshBase<ScrollView> refreshView) {
                page_num++;
                getDataFromNet();
            }
        });


    }

    /**
     * 轮播图的方法
     */
    private void lunBoTu() {
        NetDataUtil.getData("http://v3.wufazhuce.com:8000/api/reading/index/?version=3.5.0&platform=android", getActivity(), new JsonCallBack() {
            @Override
            public void getJsonString(String json) {
                //这个结合记录轮播图的所有地址
                imageUrlList = new ArrayList<String>();

                //解析数据
                Gson gson = new Gson();

                LunBoBean lunBoBean = gson.fromJson(json, LunBoBean.class);

                List<LunBoBean.DataBean.EssayBean> essay = lunBoBean.getData().getEssay();

                for (LunBoBean.DataBean.EssayBean essayBean: essay) {
                    //essayBean.getAuthor().get(0).getWeb_url()
                    imageUrlList.add(essayBean.getAuthor().get(0).getWeb_url());
                }

                //此时应该根据图片的路径,加载图片,设置适配器
                ViewPagerAdapter viewPagerAdapter = new ViewPagerAdapter(getActivity(), imageUrlList);
                viewPager.setAdapter(viewPagerAdapter);

                //1.手动可以无限滑动....maxValue....把当前开始展示的位置放在足够大的某个位置
                viewPager.setCurrentItem(imageUrlList.size()*100000);

                //2.自动轮播
                handler.sendEmptyMessageDelayed(0,2000);

            }
        });

    }

    /**
     * 下拉刷新获取数据
     */
    private void getRefreshData() {
        NetDataUtil.getData("http://gank.io/api/data/Android/10/1", getActivity(), new JsonCallBack() {
            @Override
            public void getJsonString(String json) {
                //解析
                Gson gson = new Gson();

                DataDataBean dataDataBean = gson.fromJson(json, DataDataBean.class);
                //先清空一下数据
                list.clear();

                //添加到集合的最前边,,,,(0,,,,)
                list.addAll(0,dataDataBean.getResults());

                //设置适配器
                setAdapter();

                //设置适配器之后停止刷新的操作
                refreshScrollView.onRefreshComplete();

                //可以设置刷新的时间....
                startLabels.setLastUpdatedLabel("上次更新时间:"+new SimpleDateFormat("HH:mm").format(new Date(System.currentTimeMillis())));//last最近的,最后一次update修改/更新
            }
        });

    }

    /**
     * 刚开始进入页面获取网络数据....还可以作为上拉加载获取数据的操作
     *
     *
     */
    private void getDataFromNet() {
        //第一个参数是接口,第二个上下文,第三个回调json数据
        NetDataUtil.getData("http://gank.io/api/data/Android/10/"+page_num, getActivity(), new JsonCallBack() {
            @Override
            public void getJsonString(String json) {

                //解析
                Gson gson = new Gson();

                DataDataBean dataDataBean = gson.fromJson(json, DataDataBean.class);

                //往后面添加...
                list.addAll(dataDataBean.getResults());

                //设置适配器
                setAdapter();

                //停止刷新
                refreshScrollView.onRefreshComplete();
            }
        });

    }

    /**
     * 设置适配器的方法
     */
    private void setAdapter() {
        if (listViewAdapter == null){
            listViewAdapter = new MyAdapter(getActivity(),list);
            listView.setAdapter(listViewAdapter);
        }else {
            listViewAdapter.notifyDataSetChanged();
        }

    }
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
public class Fragmentzhiyelujing extends Fragment {
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.zhiyelujing,container,false);

        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }
}


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值