推荐条+viewPager+Fragment+侧拉+多条目

主布局

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout2 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">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_weight="1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#4f0"
            />
        <android.support.design.widget.TabLayout
            android:id="@+id/tab"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#7800"
            ></android.support.design.widget.TabLayout>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/cela"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_gravity="start"
        android:background="#ff0">
        <ImageView
            android:layout_gravity="center"
            android:src="@mipmap/ic_launcher"
            android:layout_width="match_parent"
            android:layout_height="150dp" />
        <LinearLayout
            android:layout_weight="1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
                  <TextView
                android:id="@+id/text01"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="设置头像"
                android:textSize="30dp"
                android:layout_gravity="center"
                android:layout_weight="1"
                />
            <TextView
                android:id="@+id/text02"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="设置头像"
                android:textSize="30dp"
                android:layout_gravity="center"
                android:layout_weight="1"
                />
            <TextView
                android:id="@+id/text03"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="设置头像"
                android:textSize="30dp"
                android:layout_gravity="center"
                android:layout_weight="1"
                />
        </LinearLayout>
    </LinearLayout>
</android.support.v4.widget.DrawerLayout2>

fragment1

<?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"
    >
  <android.support.design.widget.TabLayout
      android:id="@+id/atab"
      android:layout_width="match_parent"
      android:layout_height="50dp"
      android:background="#990"
      />
    <android.support.v4.view.ViewPager
        android:id="@+id/aviewpager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#090"
        ></android.support.v4.view.ViewPager>
</LinearLayout>

fragment2

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">
   <TextView
       android:layout_width="0dp"
       android:layout_height="0dp"
       android:textSize="30dp"
       android:text="空白页面"
       app:layout_constraintTop_toTopOf="parent"
       app:layout_constraintLeft_toLeftOf="parent"
       app:layout_constraintRight_toRightOf="parent"
       app:layout_constraintBottom_toBottomOf="parent"
       />
</android.support.constraint.ConstraintLayout>

子fragment1

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">
   <com.handmark.pulltorefresh.library.PullToRefreshListView
       android:id="@+id/pull"
       android:layout_width="0dp"
       android:layout_height="0dp"
       app:layout_constraintTop_toTopOf="parent"
       app:layout_constraintRight_toRightOf="parent"
       app:layout_constraintLeft_toLeftOf="parent"
       app:layout_constraintBottom_toBottomOf="parent"
       ></com.handmark.pulltorefresh.library.PullToRefreshListView>
</android.support.constraint.ConstraintLayout>

子fragment2

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <com.handmark.pulltorefresh.library.PullToRefreshListView
        android:id="@+id/apull"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        ></com.handmark.pulltorefresh.library.PullToRefreshListView>
</android.support.constraint.ConstraintLayout>

布局3

<?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="wrap_content"
    android:orientation="vertical"
    >
   <TextView
       android:id="@+id/title31"
       android:layout_width="match_parent"
       android:layout_height="wrap_content" />
    <LinearLayout
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">
        <ImageView
            android:layout_weight="1"
            android:id="@+id/img31"
            android:layout_width="100dp"
            android:layout_height="80dp" />
        <ImageView
            android:layout_weight="1"
            android:id="@+id/img32"
            android:layout_width="100dp"
            android:layout_height="80dp" />
        <ImageView
            android:layout_weight="1"
            android:id="@+id/img33"
            android:layout_width="100dp"
            android:layout_height="80dp" />
    </LinearLayout>
</LinearLayout>

主布局

package com.example.dell.rop;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.dell.rop.adapter.NewsAdapter;

public class MainActivity extends AppCompatActivity {

    private ViewPager mViewpager;
    private TabLayout mTab;
    private TextView mText01;
    private TextView mText02;
    private TextView mText03;
    private LinearLayout mCela;
    private NewsAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //初始化资源
        initView();
        //添加适配器
        adapter = new NewsAdapter(getSupportFragmentManager());
        mViewpager.setAdapter(adapter);
        mTab.setupWithViewPager(mViewpager);
        //设置点击事件
        mText01.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               Toast.makeText(MainActivity.this,"0",Toast.LENGTH_SHORT).show();
               mViewpager.setCurrentItem(0);
            }
        });
        mText02.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this,"1",Toast.LENGTH_SHORT).show();
                mViewpager.setCurrentItem(1);
            }
        });
        mText03.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this,"2",Toast.LENGTH_SHORT).show();
                mViewpager.setCurrentItem(2);
            }
        });
    }

    private void initView() {
        mViewpager = (ViewPager) findViewById(R.id.viewpager);
        mTab = (TabLayout) findViewById(R.id.tab);
        mText01 = (TextView) findViewById(R.id.text01);
        mText02 = (TextView) findViewById(R.id.text02);
        mText03 = (TextView) findViewById(R.id.text03);
        mCela = (LinearLayout) findViewById(R.id.cela);
    }
}

util

package com.example.dell.rop.util;

import android.os.AsyncTask;

import com.google.gson.Gson;

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

public class NewUtil {
    public interface CallBack<T>{
        void onsuccess(T t);
    }
    public static void requestData(String e,final Class clazz,final CallBack callBack){
        new AsyncTask<String, Void, Object>() {
            @Override
            protected Object doInBackground(String... strings) {
                return requestData(strings[0],clazz);
            }

            @Override
            protected void onPostExecute(Object o) {
                callBack.onsuccess(o);
            }
        }.execute(e);
    }

    private static <T>T requestData(String string, Class clazz) {
        return (T) new Gson().fromJson(requestData(string),clazz);
    }

    private static String requestData(String string) {
        try {
            URL url = new URL(string);
            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
            urlConnection.setConnectTimeout(5000);
            urlConnection.setReadTimeout(5000);
            int responseCode = urlConnection.getResponseCode();
            if (responseCode==200){
                String s=stream2String(urlConnection.getInputStream());
                return s;
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    private static String stream2String(InputStream inputStream) throws IOException {
        StringBuilder stringBuilder = new StringBuilder();
        BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
        for (String tmp=br.readLine();tmp!=null;tmp=br.readLine()){
            stringBuilder.append(tmp);
        }
        return stringBuilder.toString();
    }
}

Afragment

package com.example.dell.rop.fragment;

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.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.dell.rop.R;
import com.example.dell.rop.adapter.aNewsAdapter;

public class AFragment extends Fragment {

    private TabLayout atab;
    private ViewPager aviewpager;
    private aNewsAdapter adapter;

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

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        aviewpager = view.findViewById(R.id.aviewpager);
        atab = view.findViewById(R.id.atab);
        //添加适配器
        adapter = new aNewsAdapter(getChildFragmentManager());
        aviewpager.setAdapter(adapter);
        atab.setupWithViewPager(aviewpager);
    }
}

BFragment

package com.example.dell.rop.fragment;

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.example.dell.rop.R;

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

子AFragment

package com.example.dell.rop.fragment;

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.ListView;

import com.example.dell.rop.Bean.Bean;
import com.example.dell.rop.R;
import com.example.dell.rop.adapter.LISTVIEWBaseAdapter;
import com.example.dell.rop.util.NewUtil;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;

public class aAFragment extends Fragment {

    private PullToRefreshListView pull;
    private LISTVIEWBaseAdapter adapter;
    private String api="http://api.expoon.com/AppNews/getNewsList/type/1/p/1";
    private int page=1;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.afragment1,container,false);
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        pull = view.findViewById(R.id.pull);
        //添加适配器
        adapter = new LISTVIEWBaseAdapter(getActivity());
        pull.setAdapter(adapter);

        pull.setMode(PullToRefreshBase.Mode.BOTH);
        pull.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
            @Override
            public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) { //下载
                page=1;
                initData();
            }

            @Override
            public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) { //刷新
              initData();
            }
        });
         initData();
    }

    private void initData() {
        NewUtil.requestData(api + page, Bean.class, new NewUtil.CallBack<Bean>() {

            @Override
            public void onsuccess(Bean bean) {
                if (page==1){
                    adapter.setList(bean.getData());
                }else{
                    adapter.addData(bean.getData());
                }
                page++;
                pull.onRefreshComplete();
            }
        });
    }
}

子BFragment

package com.example.dell.rop.fragment;

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.ListView;

import com.example.dell.rop.Bean.Bean;
import com.example.dell.rop.R;
import com.example.dell.rop.adapter.LISTVIEWBaseAdapter2;
import com.example.dell.rop.util.NewUtil;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;

public class aBFragment extends Fragment {

    private PullToRefreshListView apull;
    private LISTVIEWBaseAdapter2 adapter;
    private String api="http://api.expoon.com/AppNews/getNewsList/type/1/p/1";
    private int page=1;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.afragment2,container,false);
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        apull = view.findViewById(R.id.apull);
        //添加适配器
        adapter = new LISTVIEWBaseAdapter2(getActivity());
        apull.setAdapter(adapter);

        apull.setMode(PullToRefreshBase.Mode.BOTH);
        apull.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
            @Override
            public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) { //下载
                page=1;
                initData();
            }

            @Override
            public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) { //刷新
                initData();
            }
        });
        initData();
    }

    private void initData() {
        NewUtil.requestData(api + page, Bean.class, new NewUtil.CallBack<Bean>() {

            @Override
            public void onsuccess(Bean bean) {
                if (page==1){
                    adapter.setListTwo(bean.getData());
                }else{
                    adapter.addDataTwo(bean.getData());
                }
                page++;
                apull.onRefreshComplete();
            }
        });
    }
}

adapter

package com.example.dell.rop.adapter;

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.example.dell.rop.fragment.aAFragment;
import com.example.dell.rop.fragment.aBFragment;

public class aNewsAdapter extends FragmentPagerAdapter {
    //定义集合
    private String[] amenu=new String[]{
      "正在上映","即将上映"
    };
    public aNewsAdapter(FragmentManager fm) {
        super(fm);
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return amenu[position];
    }

    @Override
    public Fragment getItem(int i) {
        switch (i){
            case 0:
                return new aAFragment();
            case 1:
                return new aBFragment();
        }
        return null;
    }

    @Override
    public int getCount() {
        return amenu.length;
    }
}

子adapter

package com.example.dell.rop.adapter;

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.example.dell.rop.fragment.AFragment;
import com.example.dell.rop.fragment.BFragment;

public class NewsAdapter extends FragmentPagerAdapter {
    //定义一个集合
    private String[] menues=new String[]{
      "电影","资讯","视频","我的"
    };
    public NewsAdapter(FragmentManager fm) {
        super(fm);
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return menues[position];
    }

    @Override
    public Fragment getItem(int i) {
        switch (i){
            case 0:
                return new AFragment();
            case 1:
                return new BFragment();
            case 2:
                return new BFragment();
                default:
                    return new BFragment();
        }
    }

    @Override
    public int getCount() {
        return menues.length;
    }
}

列表

package com.example.dell.rop.adapter;

import android.content.Context;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.dell.rop.Bean.Bean;
import com.example.dell.rop.R;
import com.nostra13.universalimageloader.core.ImageLoader;

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

public class LISTVIEWBaseAdapter extends BaseAdapter {
     private Context context;
     private List<Bean.DataBean> list;

    public LISTVIEWBaseAdapter(Context context) {
        this.context = context;
        list=new ArrayList<>();
    }

    public void setList(List<Bean.DataBean> list1) {
        list.clear();
        if (list1!=null){
            this.list = list1;
        }
       notifyDataSetChanged();
    }
    public void addData(List<Bean.DataBean> d){
        if (d!=null){
            list.addAll(d);
        }
        notifyDataSetChanged();
    }
    //条目总数

    @Override
    public int getViewTypeCount() {
        return 3;
    }
    //条目类型

    @Override
    public int getItemViewType(int position) {
        if (position%3==0){
            return 1;
        }else if(position%2==1){
            return 0;
        }else {
            return 2;
        }

    }

    @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) {
        if (getItemViewType(position)==0){
            ViewHolder1 holder;
            if (convertView==null){
                convertView=LayoutInflater.from(context).inflate(R.layout.list1,parent,false);
                holder=new ViewHolder1(convertView);
            }else{
                holder= (ViewHolder1) convertView.getTag();
                holder.title1.setText(list.get(position).getNews_summary());
                ImageLoader.getInstance().displayImage(list.get(position).getPic_url(),holder.img1);
            }
        }else if(getItemViewType(position)==1){
            ViewHolder2 holder;
            if (convertView==null){
                convertView=LayoutInflater.from(context).inflate(R.layout.list2,parent,false);
                holder=new ViewHolder2(convertView);
            }else{
                holder= (ViewHolder2) convertView.getTag();
            }
            holder.title21.setText(list.get(position).getNews_summary());
            ImageLoader.getInstance().displayImage(list.get(position).getPic_url(),holder.img21);
            ImageLoader.getInstance().displayImage(list.get(position).getPic_url(),holder.img22);
        }else if(getItemViewType(position)==2){
            ViewHolder3 holder;
            if (convertView==null){
                convertView=LayoutInflater.from(context).inflate(R.layout.list3,parent,false);
                holder=new ViewHolder3(convertView);
            }else{
                holder= (ViewHolder3) convertView.getTag();
            }
            holder.title31.setText(list.get(position).getNews_summary());
            ImageLoader.getInstance().displayImage(list.get(position).getPic_url(),holder.img31);
            ImageLoader.getInstance().displayImage(list.get(position).getPic_url(),holder.img32);
            ImageLoader.getInstance().displayImage(list.get(position).getPic_url(),holder.img33);
        }
        return convertView;
    }
    class ViewHolder1{

        ImageView img1;
        TextView title1;

        public ViewHolder1(View convertView) {
            img1 = convertView.findViewById(R.id.img1);
            title1 = convertView.findViewById(R.id.title1);
            convertView.setTag(this);
        }
    }
    class ViewHolder2{
        ImageView img21;
        TextView title21;
        ImageView img22;
        public ViewHolder2(View convertView) {
            img21 = convertView.findViewById(R.id.img21);
            img22 = convertView.findViewById(R.id.img22);
            title21 = convertView.findViewById(R.id.title21);
            convertView.setTag(this);
        }
    }
    class ViewHolder3{
        ImageView img31;
        TextView title31;
        ImageView img32;
        ImageView img33;
        public ViewHolder3(View convertView) {
            img31 = convertView.findViewById(R.id.img31);
            img33 = convertView.findViewById(R.id.img33);
            img32 = convertView.findViewById(R.id.img32);
            title31 = convertView.findViewById(R.id.title31);
            convertView.setTag(this);
        }
    }
}

子list2

package com.example.dell.rop.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.dell.rop.Bean.Bean;
import com.example.dell.rop.R;
import com.example.dell.rop.adapter.LISTVIEWBaseAdapter;
import com.nostra13.universalimageloader.core.ImageLoader;

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

public class LISTVIEWBaseAdapter2 extends BaseAdapter {

    private Context context;
    private List<Bean.DataBean> alist;

    public LISTVIEWBaseAdapter2(Context context) {
        this.context = context;
        alist=new ArrayList<>();
    }

    public void setListTwo(List<Bean.DataBean> list2) {
        alist.clear();
        if (list2!=null){
            this.alist = list2;
        }
        notifyDataSetChanged();
    }
    public void addDataTwo(List<Bean.DataBean> d){
        if (d!=null){
            alist.addAll(d);
        }
        notifyDataSetChanged();
    }
    //条目总数

    @Override
    public int getViewTypeCount() {
        return 3;
    }
    //条目类型

    @Override
    public int getItemViewType(int position) {
        if (position%3==0){
            return 1;
        }else if(position%2==1){
            return 0;
        }else {
            return 2;
        }

    }

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

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

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

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (getItemViewType(position)==0){
            ViewHolder4 holder;
            if (convertView==null){
                convertView=LayoutInflater.from(context).inflate(R.layout.list1,parent,false);
                holder=new ViewHolder4(convertView);
            }else{
                holder= (ViewHolder4) convertView.getTag();
                holder.title1.setText(alist.get(position).getNews_summary());
                ImageLoader.getInstance().displayImage(alist.get(position).getPic_url(),holder.img1);
            }
        }else if(getItemViewType(position)==1){
            ViewHolder5 holder;
            if (convertView==null){
                convertView=LayoutInflater.from(context).inflate(R.layout.list2,parent,false);
                holder=new ViewHolder5(convertView);
            }else{
                holder= (ViewHolder5) convertView.getTag();
            }
            holder.title21.setText(alist.get(position).getNews_summary());
            ImageLoader.getInstance().displayImage(alist.get(position).getPic_url(),holder.img21);
            ImageLoader.getInstance().displayImage(alist.get(position).getPic_url(),holder.img22);
        }else if(getItemViewType(position)==2){
            ViewHolder6 holder;
            if (convertView==null){
                convertView=LayoutInflater.from(context).inflate(R.layout.list3,parent,false);
                holder=new ViewHolder6(convertView);
            }else{
                holder= (ViewHolder6) convertView.getTag();
            }
            holder.title31.setText(alist.get(position).getNews_summary());
            ImageLoader.getInstance().displayImage(alist.get(position).getPic_url(),holder.img31);
            ImageLoader.getInstance().displayImage(alist.get(position).getPic_url(),holder.img32);
            ImageLoader.getInstance().displayImage(alist.get(position).getPic_url(),holder.img33);
        }
        return convertView;
    }
    class ViewHolder4{

        ImageView img1;
        TextView title1;

        public ViewHolder4(View convertView) {
            img1 = convertView.findViewById(R.id.img1);
            title1 = convertView.findViewById(R.id.title1);
            convertView.setTag(this);
        }
    }
    class ViewHolder5{
        ImageView img21;
        TextView title21;
        ImageView img22;
        public ViewHolder5(View convertView) {
            img21 = convertView.findViewById(R.id.img21);
            img22 = convertView.findViewById(R.id.img22);
            title21 = convertView.findViewById(R.id.title21);
            convertView.setTag(this);
        }
    }
    class ViewHolder6{
        ImageView img31;
        TextView title31;
        ImageView img32;
        ImageView img33;
        public ViewHolder6(View convertView) {
            img31 = convertView.findViewById(R.id.img31);
            img33 = convertView.findViewById(R.id.img33);
            img32 = convertView.findViewById(R.id.img32);
            title31 = convertView.findViewById(R.id.title31);
            convertView.setTag(this);
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值