我正在開發一個應用程序,從而我從sqlite數據庫中檢索數據,並將數據顯示在列表視圖上我正在從特定表的兩列中檢索數據,它被添加到一個SimpleCursorAdapter然後設置爲列表視圖我想要顯示不同列中的每條記錄顯示在其自己的行當前數據從兩列顯示在一行任何幫助將被讚賞,尤其是鏈接工作示例如何從同一個表的兩列顯示光標到SimpleCursorAdapter Android
我已經deicded加入我的代碼也許這將幫助你幫助我更好
mDicCursor=managedQuery(DictionaryProvider.CONTENT_URI, null, null,
new String[] {query}, null);
if (mDicCursor == null) {
mTextView.setText(getString(R.string.no_results, new Object[] {query}));
/* final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle("WORD MISSING");*/
showDialog(DIALOG_WORDMISSING);
//new AlertDialog.Builder(this).setTitle("Argh").setMessage("Watch out!").setNeutralButton("Close", null).show();
} else {
int count = mDicCursor.getCount();
String countString = getResources().getQuantityString(R.plurals.search_results,
count, new Object[] {count, query});
mTextView.setText(countString);
/* int iWord = mDicCursor.getColumnIndexOrThrow(DictDatabase.REC_DESCRIPTION);
mTextView.setText(mDicCursor.getString(iWord));*/
// Specify the columns we want to display in the result
String[] from = new String[]{ DictDatabase.REC_WORD,
DictDatabase.REC_DESCRIPTION };
// and an array of the fields we want to bind those fields to (in this case just text1)
int[] to = new int[]{ R.id.text2,
R.id.text3};
SimpleCursorAdapter words =
new SimpleCursorAdapter(this, R.layout.dictwords, mDicCursor, from, to);
mListView.setAdapter(words);