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控件

  • 相关阅读:
    JS中iframe子页面与父页面之间通信
    .NET 大数据量并发解决方案
    angular的性能分析 -随记
    第二次作业
    自我介绍
    总结作业
    2019春第四次课程设计实验报告
    2019春第三次课程设计实验报告
    2019春第二次课程设计实验报告
    第十二周作业
  • 原文地址:https://www.cnblogs.com/qingci/p/2219597.html
Copyright © 2011-2022 走看看