編輯:關於android開發
Volley主要支持一下幾種Request
1. StringRequest:確定一個URL,獲得返回的原始字符串。
2. ImageRequest:確定一個URL,獲得一個圖片。
3. JsonObjectRequest和JsonArrayRequest: 確定一個URL,獲得JSON對象或者數字。
ImageView mImageView; String url = http://i.imgur.com/7spzG.png; mImageView = (ImageView) findViewById(R.id.myImage); ... // Retrieves an image specified by the URL, displays it in the UI. ImageRequest request = new ImageRequest(url, new Response.Listener() { @Override public void onResponse(Bitmap bitmap) { mImageView.setImageBitmap(bitmap); } }, 0, 0, null, new Response.ErrorListener() { public void onErrorResponse(VolleyError error) { mImageView.setImageResource(R.drawable.image_load_error); } }); // Access the RequestQueue through your singleton class. MySingleton.getInstance(this).addToRequestQueue(request);
ImageLoader mImageLoader; NetworkImageView mNetworkImageView; private static final String IMAGE_URL = http://developer.android.com/images/training/system-ui.png; ... // Get the NetworkImageView that will display the image. mNetworkImageView = (NetworkImageView) findViewById(R.id.networkImageView); // Get the ImageLoader through your singleton class. mImageLoader = MySingleton.getInstance(this).getImageLoader(); // Set the URL of the image that should be loaded into this view, and // specify the ImageLoader that will be used to make the request. mNetworkImageView.setImageUrl(IMAGE_URL, mImageLoader);
TextView mTxtDisplay; ImageView mImageView; mTxtDisplay = (TextView) findViewById(R.id.txtDisplay); String url = http://my-json-feed; JsonObjectRequest jsObjRequest = new JsonObjectRequest (Request.Method.GET, url, null, new Response.Listener() { @Override public void onResponse(JSONObject response) { mTxtDisplay.setText(Response: + response.toString()); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { // TODO Auto-generated method stub } }); // Access the RequestQueue through your singleton class. MySingleton.getInstance(this).addToRequestQueue(jsObjRequest);
seeting菜單界面形成--優化,seeting菜單界面--本文是上一篇文章的優化版: 上文鏈接地址:http://www.cnblogs.com/zzw1994/p/
Android java傳遞int類型數組給C,androidint接著前面的文章《Android java傳遞int類型數據給C》《Android java傳遞stri
安卓應用的界面編程(4),安卓界面編程第三組UI組件:ImageView及其子類 主要功能是顯示圖片,任何Drawable對象都可使用ImageView來顯
Unity+高通Vuforia SDK——AR播放視頻 在之前的文章中我們已經實現了基本的圖片識別,並在識別的圖片上顯示3D模型,但是有的時候我們實際上需要在