问题描述
我想知道List
or ArrayList
在android中有什么用?特别是当我们使用 AsyncTask
I want to know about What is the use of List<NameValuePair>
or ArrayList<NameValuePair>
in android? Specially when we are using web services using AsyncTask<...>
推荐答案
NameValuePair 是一个特殊的 对,用于表示 http 请求中的参数,即
www.example.com?key=value
.
NameValuePair is a special <Key, Value>
pair which is used to represent parameters in http request, i.e. www.example.com?key=value
.
NameValuePair 是一个接口,在 apache http 客户端中定义,在 java 中广泛用于处理 http 操作.List
只是一个 对的列表,将在 http post 请求中用作参数.
NameValuePair is an interface and is defined in apache http client, which is widely used in java to handle http operations. A List<NameValuePair>
is just a list of <key, value>
pairs, and will be used as params in http post request.
HttpPost request = new HttpPost();
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("key", "value"));
request.setEntity(new UrlEncodedFormEntity(params));
httpClient.execute(request);
这篇关于List<NameValuePair>有什么用?或 ArrayList<NameValuePair>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!