You can use SimpleCursorAdapter.
Image you have a list view (named 'list_item') item with two fields having ids txtOne
and txtTwo
respectively. Also, you are having a database table with tow fields - field1
and field2
.
When you sgolud use the following adapter call.
SimpleCursorAdapter adapter = new SimpleCursorAdapter(
ctx,
R.layout.list_item,
getContentResolver().query(....), // getting cursor for database query here.
new String[] { "field1", "field2" },
new int[] { R.id.txtOne, R.id.txtTwo }
);
This adapter will map a text from field1
to txtOne
and from field2
to txtTwo
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…