Professional Documents
Culture Documents
Huong Dan Lap Trinh Voi Android 21 PDF
Huong Dan Lap Trinh Voi Android 21 PDF
com
www.giaotrinhcntt.com
www.giaotrinhcntt.com
www.giaotrinhcntt.com
www.giaotrinhcntt.com
www.giaotrinhcntt.com
www.giaotrinhcntt.com
www.giaotrinhcntt.com
M:
ContentResolver cr = getContentResolver();
Cursor cursor =
cr.query(Settings.System.CONTENT_URI, null, null, null,
null);
startManagingCursor(cursor);
ListView listView = (ListView)
findViewById(R.id.listView);
String[] from = { Settings.System.NAME,
Settings.System.VALUE };
int[] to = { R.id.textName, R.id.textValue };
SimpleCursorAdapter adapter = new
SimpleCursorAdapter(this, R.layout.row, cursor, from,
to);
listView.setAdapter(adapter);
Nh cc bn thy, ch cn 2 dng code n gin ly c con tr thao tc trn
tp d liu cn ly:
M:
ContentResolver cr = getContentResolver();
Cursor cursor =
cr.query(Settings.System.CONTENT_URI, null, null, null,
null);
Lp Content Resolver cung cp cc phng thc x l d liu thng qua cc Uri,
mi Content Provider c 1 Uri c th , y Uri Settings.System.CONTENT_URI
s tr li tp d liu l thng tin cu hnh ca thit b.
Sau khi ly c con tr ti tp d liu, vic cn li n gin l bind data ln
listview hin th:
www.giaotrinhcntt.com
www.giaotrinhcntt.com
M:
startManagingCursor(cursor);
ListView listView = (ListView)
findViewById(R.id.listView);
String[] from = { Settings.System.NAME,
Settings.System.VALUE };
int[] to = { R.id.textName, R.id.textValue };
SimpleCursorAdapter adapter = new
SimpleCursorAdapter(this, R.layout.row, cursor, from,
to);
listView.setAdapter(adapter)