Android Volley.jar包下载(第三方开源网络通信框架)
16lz
2021-01-23
Android Volley下载
Android Volley是Android平台上很好用的第三方开源网络通信框架。使用简答,功能强大。
现在我把Android Volley的库jar包Volley.jar放出来供大家下载使用,下载连接地址:http://download.csdn.net/detail/zhangphil/9053413
使用方法:下载Volley.jar后,直接放到Eclipse工程的libs目录下,刷新,然后就可以调用Android Volley了。
附:
Android Volley的技术文档主页:https://developer.android.com/training/volley/index.html
Android Volley的开源代码库官方主页:https://android.googlesource.com/platform/frameworks/volley
记住加权限:
<uses-permission android:name="android.permission.INTERNET"/>
布局:
<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" tools:context="com.example.volley.MainActivity" > <ImageView android:id="@+id/imageView" android:layout_width="wrap_content" android:layout_height="wrap_content" /></RelativeLayout>
package com.example.volley;import com.android.volley.RequestQueue;import com.android.volley.Response;import com.android.volley.VolleyError;import com.android.volley.toolbox.ImageRequest;import com.android.volley.toolbox.Volley;import android.app.Activity;import android.graphics.Bitmap;import android.graphics.Bitmap.Config;import android.os.Bundle;import android.widget.ImageView;import android.widget.Toast;public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);final ImageView image=(ImageView) findViewById(R.id.imageView);//第一步,创建volley请求队列RequestQueue mQueue = Volley.newRequestQueue(this); //第二步,请求对象,imageImageRequest imageRequest = new ImageRequest("http://avatar.csdn.net/9/7/A/1_zhangphil.jpg",new Response.Listener<Bitmap>() {@Overridepublic void onResponse(Bitmap response) {//成功后加载到ImageViewimage.setImageBitmap(response);}}, 0, 0, Config.ARGB_8888, new Response.ErrorListener() {@Overridepublic void onErrorResponse(VolleyError error) {//imageView.setImageResource(R.drawable.error_image);Toast.makeText(getApplicationContext(), "错误!", Toast.LENGTH_SHORT).show();}});//第三步mQueue.add(imageRequest);/**final TextView text=(TextView) findViewById(R.id.textView);//第一步,创建volley请求队列RequestQueue mQueue = Volley.newRequestQueue(this); //第二步,new 请求对象,StringRequestStringRequest stringRequest = new StringRequest("http://www.baidu.com", new Response.Listener<String>(){//成功返回后回调@Overridepublic void onResponse(String response) {text.setText(response);}}, new Response.ErrorListener(){@Overridepublic void onErrorResponse(VolleyError error) {Toast.makeText(getApplicationContext(), "错误!", Toast.LENGTH_SHORT).show();}});//添加请求队列,启动mQueue.add(stringRequest);*/}}
更多相关文章
- 携程Android App插件化和动态加载实践
- Android异步加载源码示例
- Android Glide加载图片,宽度占满屏幕高度自适应
- android异步加载图片显示,并且对图片进行缓存实例
- android 之对象传递
- Android:浅谈app加载H5
- Android中Intent对象与Intent Filter过滤匹配过程详解