分页+frament+PullToRefresh+轮播
主页面
package com.example.zhijun.yukaolian;import android.graphics.Color; import android.os.Bundle; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button;public class MainActivity extends AppCompatActivity {private Button xqy;private Button zhuye;@Override protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);xqy = (Button) findViewById(R.id.qqy);zhuye = (Button) findViewById(R.id.zhuye);FragmentManager manager=getSupportFragmentManager();FragmentTransaction transaction = manager.beginTransaction();transaction.replace(R.id.frag,new Zhuye());transaction.commit();//主页 zhuye.setBackgroundColor(Color.RED);//详情页 xqy.setBackgroundColor(Color.GRAY);//主页的点击事件 zhuye.setOnClickListener(new View.OnClickListener() {@Override public void onClick(View view) {FragmentManager manager=getSupportFragmentManager();FragmentTransaction transaction = manager.beginTransaction();transaction.replace(R.id.frag,new Zhuye());transaction.commit();zhuye.setBackgroundColor(Color.RED);xqy.setBackgroundColor(Color.GRAY);}});//详情页的点击事件 xqy.setOnClickListener(new View.OnClickListener() {@Override public void onClick(View view) {FragmentManager manager=getSupportFragmentManager();FragmentTransaction transaction = manager.beginTransaction();transaction.replace(R.id.frag,new Xqy());transaction.commit();zhuye.setBackgroundColor(Color.GRAY);xqy.setBackgroundColor(Color.RED);}});} }
主页面
package com.example.zhijun.yukaolian;import android.os.Bundle; import android.support.annotation.Nullable; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup;import java.util.ArrayList; import java.util.List;/** * Created by zhangyueyi on 2017/9/20. */ public class Zhuye extends Fragment {private TabLayout tab;private ViewPager vp;private List<String> list;@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {View v=View.inflate(getActivity(),R.layout.zy,null);tab=v.findViewById(R.id.tab);vp=v.findViewById(R.id.vp);//标题要显示的tablayout集合 list=new ArrayList<String>();list.add("social");list.add("guonei");list.add("world");list.add("huabian");list.add("tiyu");list.add("nba");list.add("football");list.add("keji");list.add("startup");list.add("apple");//ViewPager的点击事件 vp.setAdapter(new FragmentPagerAdapter(getActivity().getSupportFragmentManager()) {@Override public CharSequence getPageTitle(int position) {//获取到下标 return list.get(position);}@Override public Fragment getItem(int position) {Fragments fragments=new Fragments();Bundle bundle=new Bundle();//通过传参的形式传到对应的参数给网络请求 if(list.get(position).endsWith("social")){bundle.putString("name","social");}else if(list.get(position).endsWith("guonei")){bundle.putString("name","guonei");}else if(list.get(position).endsWith("world")){bundle.putString("name","world");}else if(list.get(position).endsWith("huabian")){bundle.putString("name","huabian");}else if(list.get(position).endsWith("tiyu")){bundle.putString("name","tiyu");}else if(list.get(position).endsWith("nba")){bundle.putString("name","nba");}else if(list.get(position).endsWith("football")){bundle.putString("name","football");}else if(list.get(position).endsWith("keji")){bundle.putString("name","keji");}else if(list.get(position).endsWith("startup")){bundle.putString("name","startup");}else if(list.get(position).endsWith("apple")){bundle.putString("name","apple");}fragments.setArguments(bundle);return fragments;}@Override public int getCount() {//总共的条目数 return list.size();}});//tablayout和viewpager关联 tab.setupWithViewPager(vp);return v;} }
详情页
package com.example.zhijun.yukaolian;import android.content.Context; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView;import com.bigkoo.convenientbanner.ConvenientBanner; import com.bigkoo.convenientbanner.holder.CBViewHolderCreator; import com.bigkoo.convenientbanner.holder.Holder; import com.bigkoo.convenientbanner.listener.OnItemClickListener; import com.google.gson.Gson; import com.jwenfeng.library.pulltorefresh.BaseRefreshListener; import com.jwenfeng.library.pulltorefresh.PullToRefreshLayout; import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.Arrays; import java.util.List;/** * Created by zhangyueyi on 2017/9/20. */ public class Xqy extends Fragment implements OnItemClickListener {private String path;private int shu=10;private ListView xqy_lv;private GridView xqy_gv;private PullToRefreshLayout pull;ConvenientBanner conven;private Handler handler=new Handler(){@Override public void handleMessage(Message msg) {if(msg.what==0){JsonBean bean= (JsonBean) msg.obj;list = bean.getNewslist();Log.i("aaa",list.toString());myad = new Myad();xqy_gv.setAdapter(myad);myad1 = new Myad1();xqy_lv.setAdapter(myad1);}}};private List<JsonBean.NewslistBean> list;private String[] imgs=new String[]{//无线轮播请求到的网络图片实现轮播集合 "http://image.wufazhuce.com/FvVmWbqlle7jlUCTeozoval9NyBH","http://image.wufazhuce.com/FmDRnQ1XhReHRHB4jYqAPSx8htsP","http://image.wufazhuce.com/Fu6o0fqKHsI_TjdpPX3N2Kc99vNP","http://image.wufazhuce.com/FuPgOcbGDD9__fyuCdPBXb5pbA1C"};//集合 List<String> datas;ImageLoader imageLoader;private Myad myad;private Myad1 myad1;@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {//获取布局文件 View v=View.inflate(getActivity(),R.layout.xqy,null);xqy_lv = v.findViewById(R.id.xqy_lv);xqy_gv = v.findViewById(R.id.xqy_gv);conven=v.findViewById(R.id.conven);pull = v.findViewById(R.id.xqy_pull);//得到缓存图片 imageLoader=ImageLoader.getInstance();imageLoader.init(ImageLoaderConfiguration.createDefault(getActivity()));//给datas集合和图片集合绑定 datas= Arrays.asList(imgs);conven.setPages(new CBViewHolderCreator() {@Override public Object createHolder() {//用handler实现轮播 return new Ha();}},datas)//设置指示器是否可见 .setPointViewVisible(true)//设置自动切换(同时设置了切换时间间隔) .startTurning(2000)//设置两个点图片作为翻页指示器,不设置则没有指示器,可以根据自己需求自行配合自己的指示器,不需要圆点指示器可用不设 .setPageIndicator(new int[]{R.drawable.ic_page_indicator,R.drawable.ic_page_indicator_focused})//设置指示器的方向(左、中、右) .setPageIndicatorAlign(ConvenientBanner.PageIndicatorAlign.CENTER_HORIZONTAL)//设置点击事件 .setOnItemClickListener(this)//默认是TRUE .setManualPageable(true);getdata();pull.setRefreshListener(new BaseRefreshListener() {@Override public void refresh() {handler.postDelayed(new Runnable() {@Override public void run() {pull.finishRefresh();path = "http://api.tianapi.com/startup/?key=4146a52d31ee75bedb005c5b50d9c249&num="+(shu++);getdata();myad.notifyDataSetChanged();myad1.notifyDataSetChanged();}},3000);}@Override public void loadMore() {handler.postDelayed(new Runnable() {@Override public void run() {pull.finishLoadMore();path = "http://api.tianapi.com/startup/?key=4146a52d31ee75bedb005c5b50d9c249&num="+(shu++);Log.i("aaa",shu+"dfghjdcfvbghnjkxcvbn");getdata();myad.notifyDataSetChanged();myad1.notifyDataSetChanged();}},3000);}});return v;}class Myad extends BaseAdapter {private final int lin = 0;private final int one = 1;@Override public int getCount() {return list.size();}@Override public Object getItem(int i) {return null;}@Override public long getItemId(int i) {return 0;}@Override public View getView(int i, View view, ViewGroup viewGroup) {View v=View.inflate(getActivity(),R.layout.item1,null);ImageView img = v.findViewById(R.id.item_img);TextView item_text = v.findViewById(R.id.item_text);item_text.setText(list.get(i).getTitle());ImageLoader.getInstance().displayImage(list.get(i).getPicUrl(),img);return v;}}class Myad1 extends BaseAdapter {private final int lin = 0;private final int one = 1;@Override public int getCount() {return list.size();}@Override public Object getItem(int i) {return null;}@Override public long getItemId(int i) {return 0;}@Override public View getView(int i, View view, ViewGroup viewGroup) {View v=View.inflate(getActivity(),R.layout.item2,null);ImageView img = v.findViewById(R.id.item2img);TextView item_text = v.findViewById(R.id.item2text);item_text.setText(list.get(i).getTitle());ImageLoader.getInstance().displayImage(list.get(i).getPicUrl(),img);return v;}}private void getdata() {//请求网络数据 new Thread(){//开辟一个线程 @Override public void run() {//实现run方法 if(path==null) {//请求的网络地址拼接参数 path = "http://api.tianapi.com/startup/?key=4146a52d31ee75bedb005c5b50d9c249&num=" + shu;}try {//请求 URL url = new URL(path);HttpURLConnection connection = (HttpURLConnection) url.openConnection();connection.setRequestMethod("GET");//读取时间 connection.setReadTimeout(5000);//链接超时 connection.setConnectTimeout(5000);//链接成功返回200执行以下方法 if(connection.getResponseCode()==200){InputStream stream = connection.getInputStream();//解析和编码格式 String json=zhuan(stream,"utf-8");Log.i("aaa",json);Gson gson=new Gson();//解析的bean类 JsonBean fromJson = gson.fromJson(json,JsonBean.class);Log.i("aaa","aaaaaa");//发送给handler Message message = Message.obtain();message.what=0;message.obj=fromJson;handler.sendMessage(message);}} catch (Exception e) {e.printStackTrace();}super.run();}}.start();}private String zhuan(InputStream stream, String s) {//转成字节流的形式 try {//读取的流 InputStreamReader inputStreamReader=new InputStreamReader(stream,s);BufferedReader reader=new BufferedReader(inputStreamReader);String ss=null;StringBuilder builder=new StringBuilder();while((ss=reader.readLine())!=null){builder.append(ss);}inputStreamReader.close();return builder.toString();} catch (Exception e) {e.printStackTrace();}return null;}@Override public void onItemClick(int position) {}private class Ha implements Holder<String>{private ImageView imageView;@Override public View createView(Context context) {imageView=new ImageView(context);//得到图片 imageView.setScaleType(ImageView.ScaleType.FIT_XY);return imageView;}@Override public void UpdateUI(Context context, int position, String data) {ImageLoader.getInstance().displayImage(data,imageView);}} }
Frament
package com.example.zhijun.yukaolian;import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView;import com.google.gson.Gson; import com.jwenfeng.library.pulltorefresh.BaseRefreshListener; import com.jwenfeng.library.pulltorefresh.PullToRefreshLayout; import com.nostra13.universalimageloader.core.ImageLoader;import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.List;/** * Created by zhangyueyi on 2017/9/20. */ public class Fragments extends Fragment{//帮助类主要实现刷新和加载listview列表 private PullToRefreshLayout pull;private ListView pull_lv;private int shu=10;private String path;private Handler handler=new Handler(){@Override public void handleMessage(Message msg) {if(msg.what==0){JsonBean bean= (JsonBean) msg.obj;list = bean.getNewslist();Log.i("aaa",list.toString());myad = new Myad();pull_lv.setAdapter(myad);}}};private List<JsonBean.NewslistBean> list;private String s;private Myad myad;class Myad extends BaseAdapter {private final int lin=0;private final int one=1;@Override public int getCount() {return list.size();}@Override public Object getItem(int i) {return null;}@Override public long getItemId(int i) {return 0;}@Override public View getView(int i, View view, ViewGroup viewGroup) {int type=getItemViewType(i);Diyi diyi;Dier dier;switch (type){case lin:if(view==null){view=View.inflate(getActivity(),R.layout.diyi,null);diyi=new Diyi();diyi.yiimg1=view.findViewById(R.id.yiimg);diyi.yitext=view.findViewById(R.id.yitext);view.setTag(diyi);break;}case one:if(view==null){view=View.inflate(getActivity(),R.layout.dier,null);dier=new Dier();dier.erimg1=view.findViewById(R.id.erimg1);dier.erimg2=view.findViewById(R.id.erimg2);dier.erimg3=view.findViewById(R.id.erimg3);view.setTag(dier);break;}default:break;}switch (type){case lin:diyi= (Diyi) view.getTag();diyi.yitext.setText(list.get(i).getTitle());ImageLoader.getInstance().displayImage(list.get(i).getPicUrl(),diyi.yiimg1);break;case one:dier= (Dier) view.getTag();ImageLoader.getInstance().displayImage(list.get(i).getPicUrl(),dier.erimg1);ImageLoader.getInstance().displayImage(list.get(i).getPicUrl(),dier.erimg2);ImageLoader.getInstance().displayImage(list.get(i).getPicUrl(),dier.erimg3);break;default:break;}return view;}@Override public int getItemViewType(int position) {int i=position%2;if(i==0){return 0;}else{return 1;}}@Override public int getViewTypeCount() {return 2;}class Diyi{ImageView yiimg1;TextView yitext;}class Dier{ImageView erimg1,erimg2,erimg3;}}@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {View v=View.inflate(getActivity(),R.layout.fragments,null);pull = v.findViewById(R.id.pull);pull_lv = v.findViewById(R.id.pull_lv);Bundle bundle = getArguments();s = bundle.getString("name", "social");getdata(s);pull.setRefreshListener(new BaseRefreshListener() {@Override public void refresh() {handler.postDelayed(new Runnable() {@Override public void run() {shu++;path = "http://api.tianapi.com/" + s + "/?key=4146a52d31ee75bedb005c5b50d9c249&num=" + shu;getdata(s);myad.notifyDataSetChanged();pull.finishRefresh();}},3000);}@Override public void loadMore() {handler.postDelayed(new Runnable() {@Override public void run() {shu++;path = "http://api.tianapi.com/"+s+"/?key=4146a52d31ee75bedb005c5b50d9c249&num=" + shu;getdata(s);myad.notifyDataSetChanged();pull.finishLoadMore();}},3000);}});return v;}private void getdata(final String s) {new Thread(){@Override public void run() {path = "http://api.tianapi.com/" + s + "/?key=4146a52d31ee75bedb005c5b50d9c249&num=" + shu;try {URL url = new URL(path);HttpURLConnection connection = (HttpURLConnection) url.openConnection();connection.setRequestMethod("GET");connection.setReadTimeout(5000);connection.setConnectTimeout(5000);if(connection.getResponseCode()==200){InputStream stream = connection.getInputStream();String json=zhuan(stream,"utf-8");Log.i("aaa",json);Gson gson=new Gson();JsonBean fromJson = gson.fromJson(json,JsonBean.class);Log.i("aaa","aaaaaa");Message message = Message.obtain();message.what=0;message.obj=fromJson;handler.sendMessage(message);}} catch (Exception e) {e.printStackTrace();}super.run();}}.start();}private String zhuan(InputStream stream, String s) {try {InputStreamReader inputStreamReader=new InputStreamReader(stream,s);BufferedReader reader=new BufferedReader(inputStreamReader);String ss=null;StringBuilder builder=new StringBuilder();while((ss=reader.readLine())!=null){builder.append(ss);}inputStreamReader.close();return builder.toString();} catch (Exception e) {e.printStackTrace();}return null;} }
appliction
package com.example.zhijun.yukaolian;import android.app.Application;import com.nostra13.universalimageloader.core.DisplayImageOptions; import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;/** * Created by zhangyueyi on 2017/9/20. */ public class Img extends Application {//注意要在清单文件中注册name="Img" @Override public void onCreate() {//imgloder帮助类 DisplayImageOptions options=new DisplayImageOptions.Builder().showImageOnLoading(R.mipmap.ic_arrow_down).displayer(new FadeInBitmapDisplayer(2000)).cacheInMemory(true).cacheOnDisc(true).build();ImageLoaderConfiguration configuration=new ImageLoaderConfiguration.Builder(this).defaultDisplayImageOptions(options).threadPoolSize(5).build();ImageLoader.getInstance().init(configuration);} }
Bean
package com.example.zhijun.yukaolian;import java.util.List;/** * Created by zhangyueyi on 2017/9/20. */ public class JsonBean {/** * code : 200 * msg : success * newslist : [{"ctime":"2017-09-12 07:45","title":"80后团队操盘新媒体 六百岁故宫就这样炼成\u201c网红\u201d","description":"搜狐社会","picUrl":"http://photocdn.sohu.com/20170911/Img510908418_ss.jpeg","url":"http://news.sohu.com/20170911/n510908417.shtml"},{"ctime":"2017-09-04 06:40","title":"【塞罕坝造林人系列】刘军夫妇:做\u201c林场眼睛\u201d11年 无畏坚守护好绿","description":"搜狐社会","picUrl":"http://photocdn.sohu.com/20170903/Img509482875_ss.jpeg","url":"http://news.sohu.com/20170903/n509482874.shtml"},{"ctime":"2017-08-09 00:31","title":"辟谣:九寨沟县地震部分谣言网上流传 请大家不信谣不传谣","description":"搜狐社会","picUrl":"http://photocdn.sohu.com/20170809/Img505992955_ss.jpeg","url":"http://news.sohu.com/20170809/n505992954.shtml"},{"ctime":"2017-06-07 10:12","title":"舍不得媳妇套不住流氓!警察带女友约会\u201c钓色魔\u201d","description":"搜狐社会","picUrl":"","url":"http://news.sohu.com/20170607/n495984947.shtml"},{"ctime":"2017-06-06 06:19","title":"专题 | 三分钟带你看遍苹果WWDC 2017亮点","description":"网易VR","picUrl":"http://img4.cache.netease.com/photo/0009/2017-06-06/s_CM7TROL26PGI0009.jpg","url":"http://tech.163.com/special/S1496632396292/"},{"ctime":"2017-06-06 07:41","title":"2400元的音箱贵不贵?苹果HomePod现场体验","description":"网易VR","picUrl":"http://img3.cache.netease.com/photo/0009/2017-06-06/s_CM7TRJ646PGI0009.jpg","url":"http://tech.163.com/photoview/6PGI0009/15180.html"},{"ctime":"2017-06-06 08:29","title":"苹果HomePod想占据你的家,但来得太迟了","description":"网易VR","picUrl":"http://cms-bucket.nosdn.127.net/b9bd4f9b5c6f4eee89ecaf71b641df7820170606083407.jpeg","url":"http://tech.163.com/17/0606/08/CM818M3600098GJ5.html"},{"ctime":"2017-06-02 09:43","title":"武汉理工大学两男生寝室斗殴 场面血腥(组图)","description":"搜狐社会","picUrl":"","url":"http://news.sohu.com/20170602/n495366391.shtml"},{"ctime":"2017-05-24 13:13","title":"费孝通民族研究的文化内涵","description":"搜狐社会","picUrl":"","url":"http://news.sohu.com/20170524/n494263638.shtml"},{"ctime":"2017-05-23 09:15","title":"机场:中国籍乘客回国如无身份证 须办临时证明","description":"搜狐社会","picUrl":"","url":"http://news.sohu.com/20170523/n494079084.shtml"}] */ private int code;private String msg;private List<NewslistBean> newslist;public int getCode() {return code;}public void setCode(int code) {this.code = code;}public String getMsg() {return msg;}public void setMsg(String msg) {this.msg = msg;}public List<NewslistBean> getNewslist() {return newslist;}public void setNewslist(List<NewslistBean> newslist) {this.newslist = newslist;}public static class NewslistBean {/** * ctime : 2017-09-12 07:45 * title : 80后团队操盘新媒体 六百岁故宫就这样炼成“网红” * description : 搜狐社会 * picUrl : http://photocdn.sohu.com/20170911/Img510908418_ss.jpeg * url : http://news.sohu.com/20170911/n510908417.shtml */ private String ctime;private String title;private String description;private String picUrl;private String url;public String getCtime() {return ctime;}public void setCtime(String ctime) {this.ctime = ctime;}public String getTitle() {return title;}public void setTitle(String title) {this.title = title;}public String getDescription() {return description;}public void setDescription(String description) {this.description = description;}public String getPicUrl() {return picUrl;}public void setPicUrl(String picUrl) {this.picUrl = picUrl;}public String getUrl() {return url;}public void setUrl(String url) {this.url = url;}@Override public String toString() {return "NewslistBean{" +"ctime='" + ctime + '\'' +", title='" + title + '\'' +", description='" + description + '\'' +", picUrl='" + picUrl + '\'' +", url='" + url + '\'' +'}';}} }
下面是布局文件
主页
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.zhijun.yukaolian.MainActivity"><android.support.v4.widget.DrawerLayout android:layout_width="match_parent" android:layout_height="match_parent"><RelativeLayout android:layout_width="150dp" android:layout_height="match_parent" android:layout_gravity="left" android:background="#fff"><ImageView android:id="@+id/dl_img" android:layout_width="50dp" android:layout_height="50dp" android:src="@mipmap/ic_launcher" /><TextView android:id="@+id/name1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/dl_img" android:gravity="center" android:text="1509c张跃议" /><TextView android:id="@+id/xian1" android:layout_width="match_parent" android:layout_height="2dp" android:layout_below="@+id/name1" android:background="#000" /><TextView android:id="@+id/xw" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/xian1" android:gravity="center" android:text="新闻" /><TextView android:id="@+id/xian2" android:layout_width="match_parent" android:layout_height="2dp" android:layout_below="@+id/xw" android:background="#000" /><TextView android:id="@+id/yl" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/xian2" android:gravity="center" android:text="娱乐" /><TextView android:id="@+id/xian3" android:layout_width="match_parent" android:layout_height="2dp" android:layout_below="@+id/yl" android:background="#000" /><TextView android:id="@+id/sh" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/xian3" android:gravity="center" android:text="社会" /><TextView android:id="@+id/xian4" android:layout_width="match_parent" android:layout_height="2dp" android:layout_below="@+id/sh" android:background="#000" /><TextView android:id="@+id/js" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/xian4" android:gravity="center" android:text="军事" /></RelativeLayout><RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"><LinearLayout android:id="@+id/ll" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:gravity="center" android:orientation="horizontal"><Button android:id="@+id/zhuye" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="主页" /><Button android:id="@+id/qqy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="详情页" /></LinearLayout><FrameLayout android:id="@+id/frag" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/ll"></FrameLayout></RelativeLayout></android.support.v4.widget.DrawerLayout> </RelativeLayout>
详情页
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:background="#ff0" android:orientation="vertical" android:layout_height="match_parent"><com.bigkoo.convenientbanner.ConvenientBanner android:layout_width="match_parent" android:layout_height="150dp" android:id="@+id/conven"></com.bigkoo.convenientbanner.ConvenientBanner><com.jwenfeng.library.pulltorefresh.PullToRefreshLayout android:layout_width="match_parent" android:id="@+id/xqy_pull" android:layout_height="match_parent"><RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"> <GridView android:layout_width="wrap_content" android:layout_height="150dp" android:numColumns="4" android:id="@+id/xqy_gv"></GridView><ListView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/xqy_gv" android:id="@+id/xqy_lv"></ListView></RelativeLayout></com.jwenfeng.library.pulltorefresh.PullToRefreshLayout> </LinearLayout>
主页
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout 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"><android.support.design.widget.TabLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/tab" app:tabIndicatorColor="#052efc" app:tabMode="scrollable" app:tabIndicatorHeight="5dp" app:tabSelectedTextColor="#f9ec03" app:tabTextColor="#f204ce" android:fillViewport="false"></android.support.design.widget.TabLayout><android.support.v4.view.ViewPager android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/vp" android:layout_below="@+id/tab"></android.support.v4.view.ViewPager> </RelativeLayout>
item1
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:orientation="vertical" android:layout_height="match_parent"><ImageView android:id="@+id/item_img" android:layout_width="70dp" android:layout_height="70dp" /><TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/item_text" /> </LinearLayout>
item2
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:orientation="horizontal" android:layout_height="match_parent"> <ImageView android:layout_width="70dp" android:layout_height="70dp" android:id="@+id/item2img"/><TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/item2text" /> </LinearLayout>
frament
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <com.jwenfeng.library.pulltorefresh.PullToRefreshLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/pull" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true"><ListView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/pull_lv"></ListView></com.jwenfeng.library.pulltorefresh.PullToRefreshLayout> </RelativeLayout>
分页要用的第一布局
分页要用的第二布局
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:orientation="horizontal" android:layout_height="match_parent"><ImageView android:layout_width="70dp" android:layout_height="70dp" android:src="@mipmap/ic_launcher" android:id="@+id/yiimg"/><TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/yitext"/> </LinearLayout>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:orientation="horizontal" android:layout_height="match_parent"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:id="@+id/erimg1"/><ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:id="@+id/erimg2"/><ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:id="@+id/erimg3"/> </LinearLayout>
注意要添加的依赖
compile files('libs/gson-2.2.4.jar') compile 'com.jwenfeng.pulltorefresh:library:1.0.3' compile 'com.bigkoo:convenientbanner:2.0.5' compile files('libs/universal-image-loader-1.9.3-with-sources.jar') compile project(':pullToRefreshLibrary')
分页+frament+PullToRefresh+轮播相关推荐
- 响应式html轮播图,最简单的响应式jQuery轮播图插件
easySlider.js是一款轻量级.简单易用的响应式jQuery轮播图插件.easySlider.js可以根据视口的大小来动态修改轮播图的尺寸.它压缩后的版本仅5K大小,简单实用. 使用方法 在页 ...
- 【前端4】bootstrap:栅格系统,隔行/触摸换色,分页/导航条,模态框/轮播图,旅游首页
文章目录 1.bootstrap基本模板:meta/title,link/script 2.两种布局容器/栅格系统:自动补 3.样式_表格/按钮/图片/表单:class属性,for属性联动 4.组件_ ...
- unity实现图片轮播效果_Unity3D实现列表拖拽轮播分页滚动功能
在使用UGUI的ScrollRect做列表滚动时,会有分页滚动的需求,基于ScrollRect写了一个,只需要一个ScrollRect组件即可 效果截图: Threshold为滚动阈值,当翻页的长度达 ...
- 三、bootstrap4 组件(警告和提示框、徽章和面包屑、按钮按钮组、卡片、列表组、导航和选项卡、分页和进度条、巨幕和旋转图标、轮播图、折叠菜单、下拉菜单、导航条、滚动监听、轻量弹框、模态框、表单)
1.1 警告提示框 1.2 徽章和面包屑 1.3 按钮和按钮组 1.4 卡片 1.5 列表组 1.6 导航和选项卡 1.7 分页和进度条 1.8 巨幕和旋转图标 1.9 轮播图 1.10 折叠菜单 1 ...
- HTML、CSS、JS实现轮播图效果:包含分页按钮及切换箭头
HTML页面: 页面布局 <!DOCTYPE html> <html lang="en"> <head><meta charset=&qu ...
- 在vue项目中使用v-show控制元素隐藏导致swiper的轮播图及分页无法正常显示
一.需求问题 在之前的项目开发中,使用了swiper插件.由于是vue项目,对于swiper的轮播图我们使用了v-show命令,进行动态隐藏与显示.只有当点击进行一些操作以后,swiper的轮播图才会 ...
- element el-carousel 轮播图分页,一页显示n条
element el-carousel 轮播图分页,一页显示n条 html <el-carousel trigger="click" height="650px&q ...
- Vue轮播图插件---Vue-Awesome-Swiper
轮播图插件 Vue-Awesome-Swiper 地址:https://github.com/surmon-china/vue-awesome-swiper 安装:npm install vue-aw ...
- 3d饼图 vue_这是我见过最优雅的Vue图片轮播插件——Vue-Awesome-Swiper
介绍 在Web网页开发中,我们经常需要用到图片轮播,在以往传统的开发方式中有很多基于jquery的插件可供使用,但是随着目前各类前端框架层出不穷的现状,在某些方面特别是针对特定的场景,还是有不少地方不 ...
最新文章
- 解决load cycle count的一个偏方,告别硬盘卡卡响
- Caffe Windows版本的编译
- UVa1422 - Processor(二分法)
- 处理字符串_10_对字符串重新按字母排序重新组合
- 10.8 ss:查看网络状态
- 【数据结构】之算法和算法评价
- Realme首款5G手机真我X50官宣:支持SA/NSA双模5G
- 助力春运 重庆机场今晨新增一架飞机入列
- 【世界精品宝珀腕表win7主题】
- 服务器整体爆率如何修改,传奇服务端gom引擎提升爆率脚本
- 缠中说禅形态挖掘之七笔形态
- 期货开户公司想恶意滑点是做不到的
- 关于阿里云windows服务器上ping不通公网 ip 的解决思路
- 物体移动时按下Shift键加快速度
- 走进全球互联网中枢,顶级域名服务器的分布
- bamtools拆分bam文件
- linux grep正则表达式与grep用法详解
- folly库安装(4)folly依赖的重要组件安装:double-conversion, google-gflags, glog, fmt, googletest, boost等
- 非LL(1)文法到LL(1)文法的等价变换
- 【老保姆教程】:Tesseract-OCR图片文字识别