今日头条实现3秒切换文字信息(HttpConnection请求),再用HttpClient请求数据展示在ListView上
2017-11-05 20:06
585 查看
MainActivity
package com.example.week1_month11; import android.graphics.Color; import android.os.Bundle; import android.support.annotation.IdRes; import android.support.v4.app.Fragment; import android.support.v7.app.AppCompatActivity; import android.widget.FrameLayout; import android.widget.RadioButton; import android.widget.RadioGroup; import com.example.fragment.Fragment_gd; import com.example.fragment.Fragment_sy; import com.example.fragment.Fragment_tz; import com.example.fragment.Fragment_xf; public class MainActivity extends AppCompatActivity { private FrameLayout frameLayout; private RadioButton rb0; private RadioButton rb1; private RadioButton rb2; private RadioButton rb3; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //初始化组件 frameLayout = (FrameLayout) findViewById(R.id.framlay); RadioGroup radioGroup = (RadioGroup) findViewById(R.id.rg); rb0 = (RadioButton) findViewById(R.id.radio0); rb1 = (RadioButton) findViewById(R.id.radio1); rb2 = (RadioButton) findViewById(R.id.radio2); rb3 = (RadioButton) findViewById(R.id.radio3); //默认显示的页面 addFragment(new Fragment_sy()); rb0.setTextColor(Color.RED); rb1.setTextColor(Color.BLACK); rb2.setTextColor(Color.BLACK); rb3.setTextColor(Color.BLACK); radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup radioGroup, @IdRes int i) { switch (i) { case R.id.radio0: rb0.setTextColor(Color.RED); rb1.setTextColor(Color.BLACK); rb2.setTextColor(Color.BLACK); rb3.setTextColor(Color.BLACK); addFragment(new Fragment_sy()); break; case R.id.radio1: rb0.setTextColor(Color.BLACK); rb1.setTextColor(Color.RED); rb2.setTextColor(Color.BLACK); rb3.setTextColor(Color.BLACK); addFragment(new Fragment_xf()); break; case R.id.radio2: rb0.setTextColor(Color.BLACK); rb1.setTextColor(Color.BLACK); rb2.setTextColor(Color.RED); rb3.setTextColor(Color.BLACK); addFragment(new Fragment_tz()); break; case R.id.radio3: rb0.setTextColor(Color.BLACK); rb1.setTextColor(Color.BLACK); rb2.setTextColor(Color.BLACK); rb3.setTextColor(Color.RED); addFragment(new Fragment_gd()); break; default: break; } } }); } public void addFragment(Fragment fragment){ getSupportFragmentManager().beginTransaction().replace(R.id.framlay,fragment).commit(); } }在build.gradle文件中添加 useLibrary 'org.apache.http.legacy' ,
添加完之后,点击右上角按钮,进行编译
Fragment_sy
package com.example.fragment; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.AsyncTask; 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.example.Result; import com.example.week1_month11.R; import com.google.gson.Gson; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.conn.ssl.AllowAllHostnameVerifier; import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; import org.json.JSONArray; import org.json.JSONException; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.List; /** * Created by Earl on 2017/11/3. */ public class Fragment_sy extends Fragment{ private String titleUrl = "https://www.toutiao.com/hot_words/"; private ImageView iv; private List<Result.NewslistBean> newslist; ArrayList<String> titleList = new ArrayList<>(); int flag = 0; Handler handler = new Handler(){ @Override public void handleMessage(Message msg) { super.handleMessage(msg); int what = msg.what; if (what ==1 ){ if(titleList !=null){ int position = flag%titleList.size(); tv.setText(titleList.get(position)); } flag++; sendMsg(); } } }; private ListView lv; private TextView tv; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view=View.inflate(getActivity(), R.layout.fragment1,null); //初始化组件 lv = (ListView)view.findViewById(R.id.lv); tv = (TextView)view.findViewById(R.id.tv); new MlvAsyncTask().execute("https://api.tianapi.com/wxnew/?key=8d6e3228d25298f13af4fc40ce6c9679&num=10&page=1"); return view; } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); initTitlData(); } /** * 获取头条内容数据 */ private void initTitlData() { new MTitleAsyncTask().execute(titleUrl); } private class MTitleAsyncTask extends AsyncTask<String,Void,String>{ @Override protected String doInBackground(String... strings) { String netJson = NetUtil.getNetJson(strings[0]); return netJson; } @Override protected void onPostExecute(String s) { super.onPostExecute(s); try { JSONArray jsonArray = new JSONArray(s); for (int i = 0; i < jsonArray.length(); i++) { Log.e("wzq", "onPostExecute: "+jsonArray.getString(i) ); titleList.add(jsonArray.getString(i)); } sendMsg(); } catch (JSONException e) { e.printStackTrace(); } } } public void sendMsg() { //延迟发送消息; handler.sendEmptyMessageDelayed(1,3000); } //网络获取数据 class MlvAsyncTask extends AsyncTask<String,Void,String> { String str = ""; @Override protected String doInBackground(String... strings) { //因为请求的是https协议的网址,eclipse下使用HttpGet请求会报错,需要添加以下这行代码 SSLSocketFactory.getSocketFactory().setHostnameVerifier(new AllowAllHostnameVerifier()); //1.创建HttpClient HttpClient hc = new DefaultHttpClient(); //2.创键HttpGet对象 HttpGet httpGet = new HttpGet(strings[0]); //3.执行请求 try { HttpResponse response = hc.execute(httpGet); //4.得到结果吗 int code = response.getStatusLine().getStatusCode(); if(code==200){ //5.得到结果数据 HttpEntity result = response.getEntity(); String string = EntityUtils.toString(result); str = string; } } catch (IOException e) { e.printStackTrace(); } return str; } @Override protected void onPostExecute(String s) { super.onPostExecute(s); Log.e("TTTTAG",s+"++s"); Gson gson = new Gson(); Result jsonBean = gson.fromJson(s, Result.class); newslist = jsonBean.getNewslist(); MAdapter mAdapter = new MAdapter(); lv.setAdapter(mAdapter); } } //适配器 class MAdapter extends BaseAdapter { @Override public int getCount() { return newslist.size(); } @Override public Object getItem(int i) { return newslist.get(i); } @Override public long getItemId(int i) { return i; } class ViewHodel{ TextView text; ImageView image; } @Override public View getView(int i, View view, ViewGroup viewGroup) { ViewHodel vh; if(view ==null){ vh = new ViewHodel(); view = View.inflate(getActivity(),R.layout.lv_item,null); vh.text = view.findViewById(R.id.tv_title); vh.image=view.findViewById(R.id.img); view.setTag(vh); }else{ vh = (ViewHodel) view.getTag(); } vh.text.setText(newslist.get(i).getTitle()); new MAsyncTaskImage(vh.image).execute(newslist.get(i).getPicUrl()); return view; } } //网络获取图片 class MAsyncTaskImage extends AsyncTask<String,Void,Bitmap>{ ImageView image; public MAsyncTaskImage(ImageView image) { this.image = image; } @Override protected Bitmap doInBackground(String... strings) { try { URL url = new URL(strings[0]); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); int responseCode = urlConnection.getResponseCode(); if (responseCode==200){ InputStream inputStream = urlConnection.getInputStream(); Bitmap bitmap = BitmapFactory.decodeStream(inputStream); return bitmap; } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Bitmap bitmap) { super.onPostExecute(bitmap); image.setImageBitmap(bitmap); } } }
Fragment_xf
package com.example.fragment; import android.os.Bundle; 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.week1_month11.R; /** * Created by Earl on 2017/11/3. */ public class Fragment_xf extends Fragment{ @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view=View.inflate(getActivity(), R.layout.fragment2,null); return view; } }
Fragment_tz
package com.example.fragment; import android.os.Bundle; 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.week1_month11.R; /** * Created by Earl on 2017/11/3. */ public class Fragment_tz extends Fragment{ @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view=View.inflate(getActivity(), R.layout.fragment3,null); return view; } }
Fragment_gd
package com.example.fragment; import android.os.Bundle; 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.week1_month11.R; /** * Created by Earl on 2017/11/3. */ public class Fragment_gd extends Fragment{ @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view=View.inflate(getActivity(), R.layout.fragment4,null); return view; } }
NetUtil
package com.example.fragment; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.util. dbc5 Log; 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; /** * Created by Earl on 2017/11/3. */ public class NetUtil { private static String tag = "getNetJson"; public static String getNetJson(String urlString) { try { //url对象封装接口字符串 URL url = new URL(urlString); //用url打开连接, 返回值我们用HttpURLConnection HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setConnectTimeout(8000);//设置链接超时时间 int responseCode = urlConnection.getResponseCode(); //获取状态码 if (responseCode == 200) { InputStream inputStream = urlConnection.getInputStream(); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); //可拼接的字符串 StringBuilder stringBuilder = new StringBuilder(); String temp = ""; while ((temp = bufferedReader.readLine()) != null) { stringBuilder.append(temp); } String jsonString = stringBuilder.toString(); return jsonString; } else { } } catch (MalformedURLException e) { e.printStackTrace(); Log.e(tag, "getNetJson: " + e.toString()); } catch (IOException e) { e.printStackTrace(); Log.e(tag, "getNetJson: " + e.toString()); } return ""; } /** * 获取网络图片 * * @param urlString * @return */ public static Bitmap getNetBitmap(String urlString) { try { URL url = new URL(urlString); HttpURLConnection httpurlConnection = (HttpURLConnection) url.openConnection(); httpurlConnection.setConnectTimeout(8000);//设置链接超时时间 int responseCode = httpurlConnection.getResponseCode(); if (responseCode == 200) { InputStream inputStream = httpurlConnection.getInputStream(); //BitmapFactory: android提供好的加工图片的工具类, Bitmap bitmap = BitmapFactory.decodeStream(inputStream); return bitmap; } else { //do nothing } } catch (MalformedURLException e) { e.printStackTrace(); Log.e(tag, "getNetBitmap: " + e.toString()); } catch (IOException e) { e.printStackTrace(); Log.e(tag, "getNetBitmap: " + e.toString()); } return null; } }
Result
package com.example; import java.util.List; /** * Created by Earl on 2017/11/3. */ public class Result { /** * code : 200 * msg : success * newslist : [{"ctime":"2017-11-03","title":"最完美的人生,是能够容忍不完美","description":"漫心情","picUrl":"https://zxpic.gtimg.com/infonew/0/wechat_pics_-25754123.static/640","url":"https://mp.weixin.qq.com/s?src=16&ver=466×tamp=1509717646&signature=qDTqy52uavUgN4sWIvXWS4j5h92xczCGesCpk6n3Y5ou7vInJj2ALTfMwtoM5L2oSoMPdZjmCiHtLXj9rsXY2Iz-EI2SWqLAy5ZggzZxuJw="},{"ctime":"2017-11-03","title":"八句金言,很毒","description":"神州师说","picUrl":"https://zxpic.gtimg.com/infonew/0/wechat_pics_-57294953.jpg/640","url":"https://mp.weixin.qq.com/s?src=16&ver=466×tamp=1509717645&signature=Qg5-raqxU34DKd01*1BDO87b5MJo2CczA9eyfGrSLHhZ9Oo1hbK97YansNk6--H981fgkW7xK7STzPRCJmGnt5-eucfF898TtHhY7C0InZA="},{"ctime":"2017-11-03","title":"两性成熟的爱","description":"学做聪明女人","picUrl":"https://zxpic.gtimg.com/infonew/0/wechat_pics_-57295024.static/640","url":"https://mp.weixin.qq.com/s?src=16&ver=466×tamp=1509717645&signature=Yi4njbT9uzIEHXDf52ZWRRA-nWdwCdKuUJNR8fT-uZZ36JbCAkh5H8OU5IY26rxvGW9hNnZ-GAJzQZCW1EsQUkYeHdh5LhS9ZDSwwDWaKRY="},{"ctime":"2017-11-03","title":"被信任,请珍惜。","description":"正能量","picUrl":"https://zxpic.gtimg.com/infonew/0/wechat_pics_-57294518.jpg/640","url":"https://mp.weixin.qq.com/s?src=16&ver=466×tamp=1509717644&signature=TBDknITJQpIMQw-qrG0GG1kRMyhFY6f6nUYgyTl97G*7B8zqJ5uDWaGpjHRrSkms70w8UyVb45jDVfPpPbaZgLg9tnBJlHdiTFA9wWZcJ-8="},{"ctime":"2017-11-03","title":"人这一辈子\u2026\u2026","description":"正能量","picUrl":"https://zxpic.gtimg.com/infonew/0/wechat_pics_-57297923.jpg/640","url":"https://mp.weixin.qq.com/s?src=16&ver=466×tamp=1509717644&signature=giHfJPahwozDaoZpUfmMgDPtnzkG6D2H6x5S*dabgnLLP-tedpbz5d2oZnbTmXCQcva*ZGFdZq24Bht43daA5TVmUxbiZwBQNnAA9LgraEI="},{"ctime":"2017-11-03","title":"不忘人恩,不念人过,不思人非,不计人怨","description":"修心堂","picUrl":"https://zxpic.gtimg.com/infonew/0/wechat_pics_-57292693.jpg/640","url":"https://mp.weixin.qq.com/s?src=16&ver=466×tamp=1509717644&signature=ZxVbFJJfEfYut4JJHkBix-YU2cZquPZ0NYyVqxSjc3AWpRoX0UFoBWrUC9*dim8esnhWeFsYbdmj09i0wVRC1KIDqEzBjMvtZoowoSUVG00="},{"ctime":"2017-11-03","title":"不为往事扰,余生只愿笑","description":"修心堂","picUrl":"https://zxpic.gtimg.com/infonew/0/wechat_pics_-57293328.jpg/640","url":"https://mp.weixin.qq.com/s?src=16&ver=466×tamp=1509717643&signature=hS9vpxyMji5Gaw8tHc2ejqX0tZxOnjqbEyUqEbcejJDZizrE*iwXyst1WS9CeJRTQnpn0U3FqhAR27YTcRhponHBQRsv1wPtNEWpTahvzOM="},{"ctime":"2017-11-03","title":"丰富自己,比取悦别人更有力量","description":"修心堂","picUrl":"https://zxpic.gtimg.com/infonew/0/wechat_pics_-57293437.jpg/640","url":"https://mp.weixin.qq.com/s?src=16&ver=466×tamp=1509717643&signature=asd0I8QHbJYHeqVT*51kmBy72n*WfAeXe*Rk*PXnU8ueXgDkopQV2Ac2krIhutVUznP*rlxlJzfmp*nULdxXt6GI2Sxlu8cs3QpkXX2szeE="},{"ctime":"2017-11-03","title":"以后不熬夜了,漂亮比你重要,晚安~(一周精选&十一月第一期)","description":"拯救地球的蛋蛋君","picUrl":"https://zxpic.gtimg.com/infonew/0/wechat_pics_-57292924.jpg/640","url":"https://mp.weixin.qq.com/s?src=16&ver=466×tamp=1509717643&signature=Sc5i4bIJ3uT75Du9qSbGv*XPysSoP3giqI0pnthNnWRMV8X4yIL3hozL-KgNie2P-83Vu-BB0bXvgAv60e59-0q3SA-yL0WY1BFXDSU4PMk="},{"ctime":"2017-11-03","title":"与自己的灵魂交谈","description":"玫瑰音悦台","picUrl":"https://zxpic.gtimg.com/infonew/0/wechat_pics_-57292338.jpg/640","url":"https://mp.weixin.qq.com/s?src=16&ver=466×tamp=1509717642&signature=qaE3OdYwHfo1k6XXaFsOy1ah1u4TYnLNh1m868-Yi8t-Wbkh64eg*u17i2IyJRw57baHDB5E7BA5BV-HH5Zx9cV2tUvp6G*BMQ4vpWTQgm8="}] */ 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-11-03 * title : 最完美的人生,是能够容忍不完美 * description : 漫心情 * picUrl : https://zxpic.gtimg.com/infonew/0/wechat_pics_-25754123.static/640 * url : https://mp.weixin.qq.com/s?src=16&ver=466×tamp=1509717646&signature=qDTqy52uavUgN4sWIvXWS4j5h92xczCGesCpk6n3Y5ou7vInJj2ALTfMwtoM5L2oSoMPdZjmCiHtLXj9rsXY2Iz-EI2SWqLAy5ZggzZxuJw= */ 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; } } }activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:orientation="vertical" tools:context="com.example.week1_month11.MainActivity"> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:id="@+id/framlay" ></FrameLayout> <RadioGroup android:id="@+id/rg" android:layout_width="match_parent" android:layout_height="30dp" android:orientation="horizontal"> <RadioButton android:id="@+id/radio0" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:button="@null" android:gravity="center" android:text="首页" android:textSize="25sp" /> <RadioButton android:id="@+id/radio1" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:button="@null" android:gravity="center" android:text="想法" android:textSize="25sp" /> <RadioButton android:id="@+id/radio2" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:button="@null" android:gravity="center" android:text="通知" android:textSize="25sp" /> <RadioButton android:id="@+id/radio3" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:button="@null" android:gravity="center" android:text="更多" android:textSize="25sp" /> </RadioGroup> </LinearLayout>fragment1.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="60dp" android:orientation="horizontal"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/ic_launcher"/> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:id="@+id/tv"/> </LinearLayout> <ListView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/lv"></ListView> </LinearLayout>fragment2.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#33ffcc"> </LinearLayout>fragment3.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ccff00"> </LinearLayout>fragment4.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#0066ff"> </LinearLayout>lv_item.xml
<?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"> <ImageView android:layout_width="80dp" android:layout_height="80dp" android:id="@+id/img" android:src="@mipmap/ic_launcher"/> <TextView android:layout_width="match_parent" android:layout_height="80dp" android:id="@+id/tv_title" android:textSize="25sp" android:text="dssd"/> </LinearLayout>AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.week1_month11"> <uses-permission android:name="android.permission.INTERNET"/> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
相关文章推荐
- android(21)(使用HttpURLConnection,HttpClient和AsyncHttpClient分别实现post和get请求数据)
- OkHttpClient post请求今日头条数据 RecycleView显示
- Mvp设计模式实现okHttpClient请求展示在RecycleView
- HttpClient和HttpURLConnection网络请求数据
- HttpURLConnection与HttpClient的Get与Post请求数据流程
- AsyncTask异步;ListView列表展示数据 ;HttpURLConnection
- HttpUrlConnection与HttpClient的认识(二)-请求头信息的问题
- HttpUrlconnectionPsot方法请求listview展示
- HttpClient、HttpUrlConnection请求数据的方式
- Retrofit+OkHttpClient+Fresco+XRecyclerView+RxJava实现数据展示
- Android开发 httpclient Post方法实现从tomcat服务器(JSP)获取listview信息
- HttpClient和HttpURLConnection网络请求数据
- HttpUrlConnection与HttpClient的认识(二)-请求头信息的问题
- android菜鸟学习笔记24----与服务器端交互(一)使用HttpURLConnection和HttpClient请求服务端数据
- 点击侧滑任何一个 菜单项,请求网络数据展示在主界面的xlistview中且实现下拉刷新效果和上拉加载的分页加载数据效果
- HttpURLConnection请求json数据加载到ListView上
- Android使用HttpURLConnection和HttpClient请求服务器数据
- Android studio请求网络数据ListView异步加载展示文字条目 ImageLoadler加载图片
- 使用HttpUrlConnection+Handler几秒钟更换一次信息,使用HttpClient+AsyncTask请求列表信息
- DrawerLayout,TabLayout和xlistview网络请求数据(类似今日头条)