

A good example to such data-structure is this: class StateListItem Ī cursor-based adapter will be similar to that, just with a different approach to the data - as described before. In an Array-Adapter, we can make data-structure, Keeping our information aside to a selected-state information. On a cursor-based adapter, we can add a column to the DB table, making it in charge of that function. The flag representation must be for each item in the list, whether it’s a Cursor-Based adapter or an Array-Adapter, we need to make sure to have a field for that information. Make sure the selected item is painted differently than the other list items. Use the setOnItemClickListener of ListView to set a “Selected Flag” for the current item The user-experience I was looking for, was that each click on a list item will “select” it, and there will be a different button to press in order to finalize my selection, like a “Set” button under the list itself. As I needed to make such Selectable-List, I had to find the right way, using the components given to me. Apple is well known for choosing the first approach most of the times).

Their decision to make touch interaction simpler for the developer, limits the power of ListView (The old “Simplicity Control” trade-off. Long story short - they chose to ignore the “selection” of list items in touch mode! More about it on the Android Documentation. How can we do that in a touch screen? If pressing an item on the list perform a “Click” action, how can we perform a “Select” action? The Android OS developers thought about that, and decided to create a mode, called “Touch Mode”, which handles focus and selection of items differently. With keyboard, we can just press the Up and Down keys to select different items, and afterward hit “Enter” to click on the selected item, making it our “final” pick. However, it brought lots of issues regarding the handling of touch events with other inputs, like keyboard or trackball. Showing it to me 15 years ago, would’ve make me think that’s an act of pure magic! We can scroll, zoom and click with just a simple gesture, using our fingers. The touch screens brought simplicity to our lives.
