Я пытаюсь настроить просмотр списка, который получает свое содержимое из строкового массива из БД, и я хочу, чтобы элементы были помечены прямо при их создании, чтобы onItemClick дал мне тег, чтобы я мог выполнить еще одно извлечение изБД и доступ к этим данным.
мой java:
private ListView list;
private ArrayAdapter<String> adapter;
private ArrayList<String> arrayList;
//inside onCreate:
arrayList = new ArrayList<String>();
// Adapter: You need three parameters 'the context, id of the layout (it will be where the data is shown),
// and the array that contains the data
adapter = new ArrayAdapter<String>(
getApplicationContext(), android.R.layout.simple_list_item_1, arrayList);
// Here, you set the data in your ListView
list = findViewById(R.id.houseList);
list.setAdapter(adapter);
//the creation of the arraylist item:
// this line adds the data of the apartmnet and puts in your array
arrayList.add(house.getApartment() + ": " + "משפחת " + house.getName());
// next thing you have to do is check if your adapter has changed
adapter.notifyDataSetChanged();
мне нужна простая строка, которая будет передаваться в элемент здесь и позже будет извлечена с помощью onItemClick.
РЕДАКТИРОВАТЬ: мне также нужно установить уникальный цвет для каждого элемента listView в зависимости от данных, но я подозреваю, что это не очень сложно ...