我在创建整数数组时遇到错误:
mAdapter = new SimpleCursorAdapter(getBaseContext(),R.layout.lv_layout,null,new String[] { "name","photo","details"},new int[]{R.id.tv_name,R.id.iv_photo,R.id.tv_details}, 0);
我的代码:
SimpleCursorAdapter mAdapter;
MatrixCursor mMatrixCursor;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// The contacts from the contacts content provider is stored in this cursor
mMatrixCursor = new MatrixCursor(new String[] { "_id","name","photo","details"} );
// Adapter to set data in the listview
mAdapter = new SimpleCursorAdapter(getBaseContext(),R.layout.lv_layout,null,new String[] { "name","photo","details"},new int[]{R.id.tv_name,R.id.iv_photo,R.id.tv_details}, 0);
// Getting reference to listview
ListView lstContacts = (ListView) findViewById(R.id.lst_contacts);
// Setting the adapter to listview
lstContacts.setAdapter(mAdapter);
// Creating an AsyncTask object to retrieve and load listview with contacts
ListViewContactsLoader listViewContactsLoader = new ListViewContactsLoader();
// Starting the AsyncTask process to retrieve and load listview with contacts
listViewContactsLoader.execute();
}
}