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
Related
I need to create recyclerView with collapsing items. For example, I have a list of 10 items. By default, I only need to flip the first 2 elements. But by clicking on the "See all" button, I need to display all the items in the list. And vice versa, by clicking on the "Hide" button, you need to leave only the first two items in the list. Here is an example:
I suppose to implement it like this: create a flag that determines whether the full list is displayed or not, and by clicking on the button, depending on the flag, send the full list to the adapter or cut it to two elements and call notifyDataSetChanged().
But this solution seemed to me not very good, perhaps there is a more elegant solution.
Note: I don't need nested collapsing elements. I just need to display two items from a list or all items.
Please help me.
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.
The attached UI is the calllog. What i am interested is that how the horizontal menu is implemented. When click on one list item, it appeared in one line under the list item.
In the earlier android, one click on list item, we can use Context menu popup menu to show the available action to do.
I am curious that it is using expandable list view concept?
I want to design like that when click on list item to show like this, but my layout would not be the same as this one. I want to put custom layout depending on the list item type. It may include button, textview, other widgets and the layout height will not be the list item height.
Can someone give some suggestion? Thanks a lot.
I'm trying to make a screen that have an expandable categories
each category have items that when clicked i want it to be added to an element in the same screen like this pic
and when the unselect (red one) is pressed it remove it from the list
any ideas on how to implement this or suggestion for similar components
You may try using expanable-recycler-view from bignerdranch, to remove item from view, just
Remove item form data list when red button is pressed and
Notify adapter for change using notifyDataSetChanged()
Hope this help, thank you. :)
I choose an item to remove from my ListView. And after the Item was removed, my ListView was scrolled back and display at the first Item.
I want my ListView display in right place where the Item I had removed (It like remove a contact in Android Contact list). How can I do that?
I suppose you want to update your ListView display, after you remove an item, right?
When you remove the item, you have to modify your data adapter, and let the ListView change accordingly (something like the MVC pattern behavior). I've seen somewhat similar questions (and the corresponding answers :) ) here and here.
Edit:
Aha, in that case, try using setSelection(int), after recalculating new indices and new item count.