zoukankan      html  css  js  c++  java
  • android 合并数组

    我有三个数组:
    [code=java]final String[] names = mThemeResources.getStringArray(names);
    final String[] infos = mThemeResources.getStringArray(info);
    final String[] tos = mThemeResources.getStringArray(to);[/code]

    如何把这三个数组保存成一个数组例如
    {
    names[0] infos[0] tos[0],
    names[1] infos[1] tos[1],
    names[2] infos[2] tos[2],
    ...........
    }
    并且显示在Listview上,listview上每个Item有三个Textview分别对应:names,infos,tos




    1.

    用List<Map<String,String>>,Map可以放三个

    1
    2
    3
    4
    5
    6
    for(i=0;i<names.length;i++){
    map.put("name",names[i]);
    map.put("info",infos[i]);
    map.put("to",tos[i]);
    list.add(map);
    }

    差不多这样,不在eclipse里写会有少许错误你自己调试一下

    2.第一个可以帮你实现,代码如下:
    private static void test() {
    String[] name = {"1", "2", "3"};
    String info[] = {"a", "b", "c"};
    String to[] = {"?", "?", "?"};
    LinkedList<String> temp = new LinkedList<String>();//LinkedList链表结构插入快
    for (int i = 0; i < name.length; i++) {
    temp.add(name[i]);
    }
    for (int j = 0; j < info.length; j++) {
    if (j == 0) {
    temp.add(j + 1, info[j]);
    } else {
    temp.add(j * 2 + 1, info[j]);

    }
    for (int k = 0; k < to.length; k++) {
    if (k == 0) {
    temp.add(k + 2, to[k]);
    } else {
    temp.add(3 * k + 2, to[k]);
    }
    }
    System.out.println(temp.toString());
    }
    第二个也不难,不过我没有试验过。ListView的item添加TextView感觉不可行,应该是跟Item并列的TextView,像手机QQ的对话item左滑会出现一个删除按钮那样。

  • 相关阅读:
    .net Core 使用AutoMapper
    文件批量生成IO流读写
    .net Core数据的幕等性
    .net core 拦截器的使用
    墙上你APP设计与实现
    H5 App实现热更新,不需要重新安装app
    支付宝支付接口的使用详细说明
    .net 数据源DataSet 转换成模型
    .net ajax跨域请求问题
    【系统之音】SystemUI篇(二)SysytemUI功能一览--草稿
  • 原文地址:https://www.cnblogs.com/tonglingqijie/p/4783936.html
Copyright © 2011-2022 走看看