Android 传Listview 的item 数组

来源:互联网 发布:软件开发考试题 编辑:程序博客网 时间:2024/05/22 01:38
/** * 数组写法 */        List<Map<String, String>> list1 = new ArrayList<>();        HashMap map2 = new HashMap();        map2.put("add", "asdasd");        map2.put("phone", "zxcxzc");        map2.put("name", "asdasd");        map2.put("email", "asdasd");        list1.add(map2);        HashMap map = new HashMap();        String[] arr = (String[]) list1.toArray(new String[list1.size()]);        map.put("xxx", arr.toString());
List list = new ArrayList();list.add("1");list.add("2");final int size = list.size();String[] arr = (String[])list.toArray(new String[size]);

方法3:

  List<BasicNameValuePair> params = new LinkedList<BasicNameValuePair>();        params = new LinkedList<BasicNameValuePair>();        params.add(new BasicNameValuePair("param1", "Post方法"));//增加参数1        params.add(new BasicNameValuePair("param2", "第二个参数"));//增加参数2        try {            HttpPost postMethod = new HttpPost(baseUrl);//创建一个post请求            postMethod.setEntity(new UrlEncodedFormEntity(params, "utf-8")); //将参数填入POST Entity中            HttpResponse response = httpClient.execute(postMethod); //执行POST方法            Log.i(TAG, "resCode = " + response.getStatusLine().getStatusCode()); //获取响应码            Log.i(TAG, "result = " + EntityUtils.toString(response.getEntity(), "utf-8")); //获取响应内容        } catch (UnsupportedEncodingException e) {            e.printStackTrace();        } catch (ClientProtocolException e) {            e.printStackTrace();        } catch (IOException e) {            e.printStackTrace();        }


0 0
原创粉丝点击