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左滑会出现一个删除按钮那样。

  • 相关阅读:
    移动端的dl
    以resnet作为前置网络的ssd目标提取检测
    MobileNet V2
    axis
    后RCNN时代的物体检测及实例分割进展
    RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
    caffe2安装
    git学习
    各种各样的卷积核
    数字图像处理_基础知识
  • 原文地址:https://www.cnblogs.com/tonglingqijie/p/4783936.html
Copyright © 2011-2022 走看看