我正在尝试使每个项目都添加到“列表视图”中,并且可以单击,并且可以打开一个新活动来显示一些详细信息。我找不到“项目”在哪里,因为它还不存在。(我需要插入数据以使其显示在“列表视图”中。
final ListView listView = (ListView) findViewById(R.id.supplyrecordslistview);
myDB = new DatabaseHelper(this);
ArrayList<String> theList = new ArrayList<>();
Cursor data = myDB.getListContents();
if (data.getCount() == 0) {
Toast.makeText(SupplyRecords.this, "Batch List Is Empty", Toast.LENGTH_LONG).show();
} else {
while (data.moveToNext()) {
theList.add(data.getString(1));
ListAdapter listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, theList);
listView.setAdapter(listAdapter);
}
}
}
public void openMainActivity(){
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
}
public void openInputSupply(){
Intent intent = new Intent(this, InputSupply.class);
startActivity(intent);
}
}