android select multiple items in ListView? - android

I have a ListView and I want to select multiple items in the ListView without using CheckedTextView.
Please help !!

You don't really need a CheckBox. All you need is a boolean flag on your list objects. When the user clicks an item you change the state of the flag, and probably the background or text color for that list item.

I never tried it, but I would use ListView with checkbox but non visible.
Perform the setChecked(True) when the user press on an item.
I would also try changing the item background when the checkbox is checked.

Related

issue on check boxes inside listview's every child item in android

I am working on check boxes in android, I had a listview with child having one checkbox, image, textviews and their respective onclick events. I blocked at selecting only one checkbox in the entire listview child at a time. if user wants to select other item then previously selected checkbox need to be unchecked in the listview. Please suggest me . thanks in advance.

Android Custom list view with checkbox

i have list view with checkbox and if I select some item than every 9 item is selected too.
I am using onClickListener on checkbox.
Do you know how solve the situation? One item checked, but more selected.
If you wanna see my source code, just let me know and I will put there.
Thanks for help
Lukas P.
Your problem comes from views being recycled by Android. You need to store the check box state of each row in some container (eg. a list) and then explicitly set the checked state to the correct state in getView.
See this similar question:
custom ListView with checkboxes checking unchecked items

Customize checked items in ListView

I have a list view with black text items with single choice mode.
I would like the checked item to be red.
Is there any straightforward way to do this, or do I need to listen for item click callbacks, change the colors manually, etc.?
Thanks
There's nothing that will "automatically" change the background of an entire listview item based on a checkbox, so you'll pretty much have to handle the event.

List element hightlight?

I have a list and when I do setOnClickListener for an Item I don't have highlight on Items in a List.
That is not expected behavior because I want to give user a way to see which item was selected on touch.
Is there some way to make it highlighted?
tnx.
Probably you can try to set color to your list item xml. Define your list item color depending on the state. Try this out.

Android list with 'grayed out' items

In Android, I want to present the user with a list. When an item on the list is selected some action is performed, and this list item is no longer selectable. It is also 'grayed out' or the like to indicate that it cannot be selected the next time the list is displayed. I have seen the isSelectable() override in Adapter, but I believe this causes the item to be treated as a separator, which causes visual problems. And I have not found a way to 'gray out' an item. Any ideas? Thanks...
As far as graying out an item. I'm not sure if this is the best way, but it's what I do:
view.setAlpha(75);
view.setBackgroundColor(Color.GRAY);
I'm basically making the item transparent and then setting the background color to gray. If you're reusing your list items you should also change them back to their original state if the condition is not met, i.e.:
view.setAlpha(255);
view.setBackgroundColor(Color.WHITE);
that is, if your original state was no transparency and the background color was white.
You need the view to be disabled. If you are creating the views just call .setDisabled(boolean) on the top view. Setting the list item to be disabled doesn't work very well in my experience.
Here is the solution I am using. I set up an OnItemClickListener for my ListView. When an item in the list is clicked, I take the passed in View and call setEnabled(false) on it. This will gray out the item. However, subsequent clicks on this item will still call the onItemClick method. So, you will need to check on each click if the item is enabled/disabled and act accordingly.

Categories

Resources