Skip to content

Instantly share code, notes, and snippets.

@chiemy
Created September 15, 2014 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chiemy/fe4ec89f7e6e68b01838 to your computer and use it in GitHub Desktop.
Save chiemy/fe4ec89f7e6e68b01838 to your computer and use it in GitHub Desktop.
// Defines a list of columns to retrieve from the Cursor and load into an output row
String[] mWordListColumns ={
UserDictionary.Words.WORD, // Contract class constant containing the word column name UserDictionary.Words.LOCALE // Contract class constant containing the locale column name
};
// Defines a list of View IDs that will receive the Cursor columns for each row
int[] mWordListItems = { R.id.dictWord, R.id.locale};
// Creates a new SimpleCursorAdapter
mCursorAdapter = new SimpleCursorAdapter(
getApplicationContext(), // 上下文对象
R.layout.wordlistrow, // ListView的Item(一行)
mCursor, // 查询结果
mWordListColumns, // cursor中列名数组
mWordListItems, // 在Item布局中,每个View的id
0); // Flags (usually none are needed)
// 为ListView设置适配器
mWordList.setAdapter(mCursorAdapter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment