我必须在我的应用程序中将一个数组列表拆分为多个字符串,这些字符串应该按顺序显示..
ArrayList<String> contactlist = new ArrayList<String>();
contactlist.add("Prasad");
contactlist.add("Prasad");
contactlist.add("Prasad");
contactlist.add("Prasad");
String[] contact = new String[contactlist.size()];
contact = contactlist.toArray(contact);
StringBuffer sb = new StringBuffer("");
for (String s : contactlist) {
sb.append(s+",");
}
stringToSend = sb.toString();
Log.d("stringToSend ", stringToSend);
new upload().execute();
/*
* String[] rString = stringToSend.split("-");
*
* for (String s : rString) { System.out.println("Names : " +
* s); }
*/
}
});
}
class upload extends AsyncTask<Void, Void, Void> {
String res, res1, url;
ProgressDialog pd;
protected void onPreExecute() {
pd = ProgressDialog.show(MainActivity.this, "Sending",
"Please Wait");
}
@Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
try {
res = null;
url = "http://192.168.0.40:8092/Testing/Login";
//res = CustomHttpClient.executeHttpGet(url).trim();
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("name", stringToSend));
res = CustomHttpClient.executeHttpPost(url, nameValuePairs);
} catch (Exception e) {
// TODO: handle exception
}
return null;
}
protected void onPostExecute(Void unused) {
pd.dismiss();
if (res != null) {
Toast.makeText(MainActivity.this, "res", 1000).show();
}
}
我得到的回应是 prasad,prasad,prasad,prasad
我应该得到回应
普拉萨德
普拉萨德
普拉萨德
普拉萨德
我该怎么做呢?