Android 如何使用json在arraylist中调用id参数存储
在这个方法中工作正常但id参数不工作,请帮助我 如何获取id以及如何存储idAndroid 如何使用json在arraylist中调用id参数存储,android,Android,在这个方法中工作正常但id参数不工作,请帮助我 如何获取id以及如何存储id public void getAccountDetail_httpCall( ) { try { int TIMEOUT_MILLISEC = 10000; // = 10 seconds String param1="25"; HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnect
public void getAccountDetail_httpCall( ) {
try {
int TIMEOUT_MILLISEC = 10000; // = 10 seconds
String param1="25";
HttpParams httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParams,TIMEOUT_MILLISEC);
HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC);
HttpParams p = new BasicHttpParams();
p.setParameter("id", param1);//param1
// Instantiate an HttpClient
HttpClient httpclient = new DefaultHttpClient(p);
String url="http://www.tranzlogix.comtranzlogix_webserviceonesms.php?smsid="+param1+"&format=json";//param1
HttpPost httppost = new HttpPost(url);
// Instantiate a GET HTTP method
try {
Log.i(getClass().getSimpleName(), "web service called-----");
Log.i(getClass().getSimpleName(),"URL---"+url);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("id", param1));//param1
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = httpclient.execute(httppost,
responseHandler);
Log.i(getClass().getSimpleName(), "responseBody----"+responseBody);
JSONObject json = new JSONObject(responseBody);
JSONArray jArray = json.getJSONArray("posts");
for (int i = 0; i < jArray.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
JSONObject e = jArray.getJSONObject(i);
String s = e.getString("post");
JSONObject jObject = new JSONObject(s);
map.put("message", jObject.getString("message"));
map.put("mobile", jObject.getString("mobile"));
map.put("id", jObject.getString("id"));
Util.mylist.add(map);
}
for(int i=0;i<=Util.mylist.size();i++){
Util.mobile.add(Util.mylist.get(i).get("mobile"));
Util.id.add(Util.mylist.get(i).get("id"));
Util.message.add(Util.mylist.get(i).get("message"));
Log.i(getClass().getSimpleName(), "mobile no's----"+Util.mylist.get(i).get("mobile"));
Log.i(getClass().getSimpleName(), "id no's----"+Util.mylist.get(i).get("id"));
Log.i(getClass().getSimpleName(), "message's----"+Util.mylist.get(i).get("message"));
String phoneNo = Util.mylist.get(i).get("mobile");
//String phoneNo = Util.mylist.get(i).get("id");
String message =Util. mylist.get(i).get("message");
if (phoneNo.length()>0 && message.length()>0)
sendSMS(phoneNo, message);
else
Toast.makeText(getBaseContext(),
"Please enter both phone number and message.",
Toast.LENGTH_SHORT).show();
}
// new PaymentSubmit().execute();
// Util.id=mylist.get(0).get("id");
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} catch (Throwable t) {
}
如何设置多个参数…您可以指定ID为的问题吗?你指的是什么多个参数?我得到一个包含许多数据的id,并将其存储在arraylist中,我必须在带有参数的URL中调用该id,以便自动调用arraylist中的所有数据。目前,我正在手动设置数组列表的位置如何设置arraylist的整个数据。。