SimpleAdapter 和 SimpleCursorAdapter的使用

 

 

 

SimpleAdapter

ArrayList<HashMap<String,Object>> arr = new ArrayList<HashMap<String,Object>>(); HashMap<String,Object> map = new HashMap<String,Object>(); map.put("image", R.drawable.icon); map.put("text","杨锐"); arr.add(map); map = new HashMap<String,Object>(); map.put("image", R.drawable.icon); map.put("text","谢剑"); arr.add(map); map = new HashMap<String,Object>(); map.put("image", R.drawable.icon); map.put("text","李晨"); arr.add(map); map = new HashMap<String,Object>(); map.put("image", R.drawable.icon); map.put("text","郑慧东"); arr.add(map); SimpleAdapter sla = new SimpleAdapter(this,arr,R.layout.layout22, new String[]{"image","text"}, new int[]{R.id.iv,R.id.tv}); SimpleCursorAdapter sca = new SimpleCursorAdapter( this,R.layout.layout22,cursor, new String[]{"_id","username","phone","types","nowtime"}, new int[]{R.id.tv,R.id.tv1,R.id.tv2,R.id.tv3,R.id.tv4}); 

 

SimpleCursorAdapter

protected Cursor getList() { Cursor cursor = null; sqlbase = this.getReadableDatabase(); try { cursor = sqlbase.query(tableName, new String[]{"_id"},null,null,null,null,null); cursor.getCount(); } catch (SQLiteException e) { Log.e("!!!!!!", "getList ERROR"); closeCon(); } closeCon(); return cursor; } Cursor cursor = db.getList(); SimpleCursorAdapter sca = new SimpleCursorAdapter( this,R.layout.layout22,cursor, new String[]{"_id"}, new int[]{R.id.tv}); ListView lv = (ListView) findViewById(R.id.listv); lv.setAdapter(sca); break; 

 

 

你可能感兴趣的:(image,object,ListView,String,null,Types)