如何从android向服务器发送多个值 public boolean setContacts(字符串名称、字符串编号){ 服务URL=”http://...../sample.php?method=setcontacts"; ArrayList nameValuePairs=新的ArrayList(); 添加(新的BasicNameValuePair(“name”,name)); 添加(新的BasicNameValuePair(“num”,number)); 试一试{ httpClient=新的DefaultHttpClient(); httpPost=新的httpPost(serviceUrl); setEntity(新的UrlEncodedFormEntity(nameValuePairs)); HttpResponse HttpResponse=httpClient.execute(httpPost); .................. }
在这段代码中,我向服务器发送了一行名称和编号,该行工作正常, 但我想发送一份姓名和号码列表,如如何从android向服务器发送多个值 public boolean setContacts(字符串名称、字符串编号){ 服务URL=”http://...../sample.php?method=setcontacts"; ArrayList nameValuePairs=新的ArrayList(); 添加(新的BasicNameValuePair(“name”,name)); 添加(新的BasicNameValuePair(“num”,number)); 试一试{ httpClient=新的DefaultHttpClient(); httpPost=新的httpPost(serviceUrl); setEntity(新的UrlEncodedFormEntity(nameValuePairs)); HttpResponse HttpResponse=httpClient.execute(httpPost); .................. },http,Http,在这段代码中,我向服务器发送了一行名称和编号,该行工作正常, 但我想发送一份姓名和号码列表,如 public boolean setContacts(String name, String number) { serviceUrl = "http://...../sample.php?method=setcontacts"; ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair&g
public boolean setContacts(String name, String number) {
serviceUrl = "http://...../sample.php?method=setcontacts";
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("name", name));
nameValuePairs.add(new BasicNameValuePair("num", number));
try {
httpClient = new DefaultHttpClient();
httpPost = new HttpPost(serviceUrl);
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse httpResponse = httpClient.execute(httpPost);
..................
}
ArrayList contactsList=。。。。。。。。。。。。。。。;
那么我如何实现这个呢
ArrayList<Strng[]> contactsList =...............;
public boolean setContacts(ArrayList contacts列表){
}
如果您有其他方法,请提前向我表示感谢。将信息序列化为字符串,并将其发送到帖子正文中。给这只猫剥皮的方法有很多,但三大方法是:
public boolean setContacts(ArrayList<String[]> contactsList) {
}