Making an ListItem as Favourite in ExpandableListView - android

I am populating an ExpandableListView and when the user clicks on the item the child items open.
Can I have an child item named as favourite, when ever the user clicks on this list it will be favourite and the color of these listview changes after clicking on the favourite button.
How to achieve this, any help would be great.
Looking forward to your reply.
thanks.

Use styles for changing the colours dynamically. Set the style of the view from the code to change the same on the click.
Place any views in hidden state and enable and disable them on time according to ur requirement. For ex showing STAR for the favourite.

Related

how to show and hide buttons in listView

As shown in the image when I click on an item in the list view. Buttons show up.
I want to hide buttons when I click on different items and show on current clicked item.
How can I make it work?
Need to preserve view into a variable like prevView. and then click on another item.
Check whether prevView is null or not. If not null. then get button id .
e.g. prevView.findViewById();
and Make their visibility.GONE. and also null prevView.
I hope this will help you.
You can achieve this by making a model class.
take variable for particular buttons in Model. after clicking on a different item set true/false tag in the model and show/hide view according to that tag.
You should be using an expandable ListView so that you can get the buttons shown when you tap on the list item and it get closed when you tap on the other item in the list.

How to add a small icon to item listview when that item is on click?

I have a ListView and each item have a TextView.
I would like add a small icon when user click in that item. (when user click other, icon hide and show in the other)
any ideas, examples or tutorials?
thanks
You are going to need a custom ListViewAdapter. This website has a good tutorial:
http://www.ezzylearning.com/tutorial.aspx?tid=1763429
You could put an OnClickListener on each list item that associates the icon with that item and programmatically add the icon to its layout, while removing it from the previous' layout. So you'll want to have a variable that holds the current layout that is associated with the icon, and when a new item is clicked you remove the icon from that layout, then set the variable to this new item's layout.

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.

How to display "More" list item in ListView?

I want to display a list item that says "More" at the end of my ListView. Clicking on this list-item will perform some action. How can I create this "more" list item?
I don't know about the "Clicking on this list-item will perform some action" part. The typical pattern is that once the user scrolls to the bottom, new material is loaded automatically. Some people do that by detecting the scroll. I do it by putting in a "More" placeholder and detecting when that is used. Here is a component that implements this pattern.
Just add another value to your arrayadapter (or any other adapter), you might be using.set the text to 'more' .
Suppose you have n items in the list then handle the (n+1)th postion click and do your stuff.
You can add a footer to your listview...
Did you check this post out?
Android ListView Footer View not being placed on the bottom of the screen

android select multiple items in ListView?

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.

Categories

Resources