zoukankan      html  css  js  c++  java
  • 把一个HashMap的值全部取出来,放到两个数组中

    先是从数据库中获取所有的值,返回一个HashMap类型的数据:
    <pre name="code" class="java">	private HashMap<String, String> searchSql() {
    		int columnsSize = cursor.getColumnCount();
    		HashMap<String, String> map = new HashMap<String, String>();
    		if (cursor != null) {
    			while (cursor.moveToNext()) {
    				System.out.println("设备名称ID " + cursor.getString(1)
    						+ "<--------->" + cursor.getString(0));
    				for (int i = 0; i < columnsSize; i++) {
    					map.put(cursor.getString(1), cursor.getString(0));
    				}
    			}
    		}
    		return map;
    	}


    
    
    然后保存包
    <pre name="code" class="java">		HashMap<String, String> map =searchSql();//返回的map
    		List<String> keyList = new ArrayList<String>(map.keySet());
    		List<String> valueList = new ArrayList<String>(map.values());
    		for(int i = 0; i < map.size(); i++){
    			System.out.println("测试 " + valueList.get(i));
    			tableView.addBasicItem(new BasicItem(keyList.get(i),valueList.get(i) , false));//用的UItable开源控件,显示在listview中
    		}


    
    
    
  • 相关阅读:
    leetcode 11. 盛最多水的容器
    gluoncv 导入方式
    python import
    leetcode 55.跳跃游戏
    leetcode 31. 下一个排列
    gluoncv 下载预训练模型速度太慢
    gluoncv voc_detection
    shuf 按行打乱文本命令
    __call__
    @property 装饰器
  • 原文地址:https://www.cnblogs.com/sowhat4999/p/4439853.html
Copyright © 2011-2022 走看看