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中
    		}


    
    
    
  • 相关阅读:
    X509IncludeOption 枚举
    SHA-1算法——(2)
    SHA-1算法
    消息摘要算法
    Oid 类
    @param注解
    类X509Certificate2
    sq分页
    svn不是内部或外部命令?
    PhpStorm配置svn:Can't use Subversion command line client:svn
  • 原文地址:https://www.cnblogs.com/sowhat4999/p/4439853.html
Copyright © 2011-2022 走看看