我正在尝试从服务器解析图像,并且我正在使用查询,在我的 Logcat 响应中显示但图像未显示!以下是我对 Json 和代码片段的回应。
任何人都可以帮忙吗?
[
{
"b_card":"http:\/\/www.webname.com\/uploaded\/users\/vcard\/8_ers.jpg"
}
]
和 BusinessCard.java:
public class BusinessCard extends Activity{
private Button btn;
private String User_id;
private Activity activity;
private ImageView bucard;
ImageLoader _DownImageLoader;
AQuery androidAQuery=new AQuery(this);
JSONArray state_list=null;
private static String ALL_SUBCATAGORY_URL = "";
private static final String ALL_SUBCATAGORY_ID="b_card";
ArrayList<HashMap<String,String>> subcatagorydata;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.business_card);
User_id=this.getIntent().getStringExtra("userids");
System.out.println("for business card"+User_id);
ALL_SUBCATAGORY_URL="http://www.asdf.com/web-service/b_card.php?user_id="+User_id;
/*ImageLoader imageLoader = new ImageLoader(activity.getApplicationContext());
ImageView Profileimage = (ImageView) findViewById(R.id.You_image_view);
imageLoader.DisplayImage(imageurl , Profileimage);*/
bucard=(ImageView)findViewById(R.id.imgvwbusinesscard);
btn=(Button)findViewById(R.id.dwnldbutton);
_DownImageLoader = new ImageLoader(activity);
bucard.setTag(ALL_SUBCATAGORY_URL); //set url tag to image
_DownImageLoader.DisplayImage(ALL_SUBCATAGORY_URL, activity ,bucard);
new LoadAllSubcatagories().execute();
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
});
}
class LoadAllSubcatagories extends AsyncTask<String, String, ArrayList<HashMap<String,String>>> {
ArrayAdapter<String> adapterallsubcatagory ;
private ProgressDialog pDialog;
@Override
protected void onPreExecute() {
super.onPreExecute();
/* pDialog = new ProgressDialog(MainActivity.this);
pDialog.setMessage("Load All Subcatagories..");
pDialog.setIndeterminate(false);
// pDialog.setIndeterminateDrawable(getResources().getDrawable(R.drawable.custom_progress));
pDialog.setCancelable(true);
pDialog.show();*/
}
protected ArrayList<HashMap<String,String>> doInBackground(String... args) {
ServiceHandler sh = new ServiceHandler();
// Making a request to url and getting response
subcatagorydata = new ArrayList<HashMap<String, String>>();
String jsonStr = sh.makeServiceCall(ALL_SUBCATAGORY_URL, ServiceHandler.GET);
Log.d("Response: ", "> " + jsonStr);
if (jsonStr != null) {
try {
//JSONObject jsonObj = new JSONObject(jsonStr);
// Getting JSON Array node
//JSONArray data_array = new JSONArray(received);
state_list = new JSONArray(jsonStr);
// looping through All Contacts
for (int i = 0; i < state_list.length(); i++) {
JSONObject c = state_list.getJSONObject(i);
String card=state_list.getJSONObject(i).toString();
System.out.println("Card "+card);
androidAQuery.id(bucard).image(card, true, true);
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// adding each child node to HashMap key => value
map.put(ALL_SUBCATAGORY_ID, c.getString(ALL_SUBCATAGORY_ID));
subcatagorydata.add(map);
}
} catch (JSONException e) {
e.printStackTrace();
}
} else {
Log.e("ServiceHandler", "Couldn't get any data from the url");
}
return subcatagorydata;
}
protected void onPostExecute(ArrayList<HashMap<String,String>> result) {
}
}
}