0
我正在尝试使用产品填充列表视图。我可以做到,但我需要他们有自定义ID(SQLite数据库中的)。我怎样才能做到这一点?这是我的代码没有ID执行迄今:ListView中的自定义ID
ArrayList<String> productNameList = new ArrayList<String>();
ArrayList<String> productIdList = new ArrayList<String>();
Cursor results = myDbHelper.getProducts();
ListView lv = (ListView) findViewById(R.id.productlist);
while (results.moveToNext()){
productNameList.add(results.getString(results.getColumnIndex("name")));
productIdList.add(results.getString(results.getColumnIndex("id")));
}
lv.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , productNameList));
“to”和my_cell_layout是什么?谢谢。 –
我编辑了代码 – thaussma