我有一个ListView,我想在加载后以编程方式突出显示多行。
问题:我突出显示它们的代码(通过setSelection())没有任何效果。
问题:您知道为什么我的行没有突出显示以及如何修复代码吗?
我将ListView属性设置为允许多个选项:
ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, assetBookingsStringArray);
assetBookingsListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
assetBookingsListView.setAdapter(adapter);
代码点,我检查哪些行应突出显示,尝试突出显示:
ArrayList<Integer> bookingConflicts = getConflicts(assetBookings);
if (bookingConflicts.size() > 0) {
Toast.makeText(getContext(), "We could not book your request because there are other conflicting bookings conflicting with yours, please choose another time period...", Toast.LENGTH_LONG).show();
for(Integer i: bookingConflicts) {
assetBookingsListView.setSelection(i.intValue());
}
}