Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make items within ListView selectable

I am working on an android application and I am trying to follow the guidelines for the Ice Cream Sandwich UI.

I have a ListActivity which contains a ListView and within the ListView I am have a TextView for each item within an ArrayAdapter. When I want to be able to do, is once the user long clicks on an item within the ListView and Context Activity Bar is shown and the item that was long clicked is now in a selected state. From there the user can then click on multiple items within the ListView making them all selected and then the user can press a button within the ActionBar to perform an action on all selected items within the ListView.

I've got it triggering to show the context activity bar when the item is long clicked but I have no idea how I can make the item appear selected and allow the user to select/deselect the items within the ListView.

Thanks for your help

like image 716
Boardy Avatar asked Jun 16 '12 14:06

Boardy


People also ask

How do I make a list selectable?

Use the <select> tag to create a selectable list. The HTML <select> tag is used within a form for defining a select list.

How to get data from ListView by clicking item on ListView?

Try this: my_listview. setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { } });

What is setAdapter in android?

In order to display items in the list, call setAdapter(android. widget. ListAdapter) to associate an adapter with the list. For a simple example, see the discussion of filling an adapter view with text in the Layouts guide. To display a more custom view for each item in your dataset, implement a ListAdapter.


1 Answers

Do as is described here.

How to highlight selected item in ListView?

Basically you need to set the multiselect listener and then selection type. Do what you need from the actionmode callbacks

like image 88
Jug6ernaut Avatar answered Sep 29 '22 15:09

Jug6ernaut