MatrixCursor的简单使用

废话不多说直接贴代码:
public class List1 extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.main);
String[] menuCols = new String[] {"_id", "item", "price" };
int[] to = new int[] { R.id.icon, R.id.item, R.id.price };
MatrixCursor menuCursor = new MatrixCursor(menuCols);
startManagingCursor(menuCursor);
menuCursor.addRow(new Object[] { R.drawable.icon, "Chicken Sandwich", "$3.99" });
ListAdapter menuItems = new SimpleCursorAdapter( this, R.layout.menu_row, menuCursor, menuCols, to);
setListAdapter(menuItems);
}
}


android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">

android:layout_width="wrap_content"
android:layout_height="wrap_content">

android:layout_width="wrap_content" android:layout_height="wrap_content">

android:layout_width="wrap_content"
android:layout_height="wrap_content">


实现的效果 图片 Chicken Sandwich $3.99
这个的好处是现实图片比较快速 用起来方便

你可能感兴趣的:(android)