zoukankan      html  css  js  c++  java
  • Android绑定对象到ListView中(知识积累)

    public void bindToListView(List<Forecast_conditions> conditionsList)
        {
        	 //SimpleAdapter simpleAdapter=new SimpleAdapter(this,conditionsList,R.layout.list_item, new String[]{"day_of_week","low","high","icon","condition"},new int[]{R.id.WeekTextView,R.id.lowTextView,R.id.HighTextView,R.id.imageView1,R.id.CondtionTextView});
        	
        //	SimpleAdapter simpleAdapter=new 
        	 
        	// m_weatherListView.setAdapter(simpleAdapter);\
        	
        	List<HashMap<String, Object>> hashMaplst=new ArrayList<HashMap<String,Object>>();
        	
        	for (Forecast_conditions forecast_conditions : conditionsList) {
    			HashMap<String, Object> item=new HashMap<String, Object>();
    			item.put("day_of_week", forecast_conditions.getDay_of_week());
    			item.put("low", forecast_conditions.getLow());
    			item.put("high", forecast_conditions.getHigh());
    			item.put("icon", forecast_conditions.getHigh());
    			item.put("condition", forecast_conditions.getCondition());
    			
    			hashMaplst.add(item);
    		}
        	
        	SimpleAdapter simpleAdapter=new SimpleAdapter(this,hashMaplst,R.layout.list_item, new String[]{"day_of_week","low","high","icon","condition"},new int[]{R.id.WeekTextView,R.id.lowTextView,R.id.HighTextView,R.id.imageView1,R.id.CondtionTextView});
        	m_weatherListView.setAdapter(simpleAdapter);
        	
        	 
        }
    
    
    //Forecast_conditions 是实体类
    //本实例是第一次做Android从各方查来写的代码,很多地方设计不合理。  所以仅供参考  -。-
    

      m_weatherListView是ListView控件

  • 相关阅读:
    二叉树基本操作(二)
    二叉树基本操作(一)
    数组的方式实现--栈 数制转换
    数据的插入与删除
    链表 创建 插入 删除 查找 合并
    ACM3 求最值
    ACM2 斐波那契数列
    ACM_1 大数求和
    简单二维码生成及解码代码:
    ORM中去除反射,添加Expression
  • 原文地址:https://www.cnblogs.com/qingci/p/2219597.html
Copyright © 2011-2022 走看看