I am trying to make a simple interface that allows the user to select a single item in a list by tapping and then press a button to remove it. I have the choice mode on the list set to singleChoice but whenever I tap a item it highlights for a brief moment the goes back to normal. Whenever I press the remove button the getSelectedItem and getSelected View return null. Here is the ListView code:
<ListView android:id="@+id/times"
android:choiceMode="singleChoice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/time"
android:layout_above="@+id/every"/>
This is the method called on remove, where list is the ListView and adapt is its ArrayAdapter, using an ArrayList.
public void remove(View view)
{
System.out.println(list.getSelectedItem()+"\n"+list.getSelectedView());
adapt.remove((String)list.getSelectedItem());
}
Edit: I am trying to make this app's minimum API level 10 in case that helps.