Code example for SimpleCursorAdapter

Methods: newView

0
		@Override 
		public View newView(Context context, Cursor cursor, ViewGroup parent) { 
			if (getItemViewType(cursor.getPosition()) == GROUP_VIEW_TYPE) { 
				return LayoutInflater.from(context).inflate(android.R.layout.preference_category, null); 
			} else 
				return super.newView(context, cursor, parent); 
		} 
 
		@Override 
		public void bindView(View convertView, Context context, Cursor cursor) { 
			if (getItemViewType(cursor.getPosition()) == GROUP_VIEW_TYPE) { 
				TextView tv = (TextView)convertView; 
				String key = cursor.getString(MappingCursorLoader.GROUP_CURSOR_COLUMN_KEY); 
				int size = cursor.getInt(MappingCursorLoader.GROUP_CURSOR_COLUMN_SIZE); 
				boolean isExpanded = MappingCursorLoader.getRowType(cursor) == MappingCursorLoader.ROW_TYPE_GROUP_EXPANDED; 
				tv.setText((isExpanded ? "¡å" : "¢º") + " "+key+" ("+size+")"); 
			} else { 
				super.bindView(convertView, context, cursor); 
				TextView tv = (TextView)convertView.findViewById(android.R.id.text1); 
				if (cursor.getInt(CheeseTable.COLUMN_INDEX_FLAG1) == 1) 
					tv.setTextColor(Color.YELLOW);