How do I animate ListView item hights? - android

I have a simple ListView in my application. What I want to do on a row select is to expand it and show additional details in there and then if some other is selected then collapse the previous one and expand the new one.
I can modify the contents list item row in onListItemClick() method. However how do I animate the change in height of the list item row.
Is there a better way to do it? Or is there a better component still? I don't want to use the expandable list as it's not a group of child lists, instead just expanding the contents with more details.
Any help is much appreciated.
Cheers

Have a look at Lazylist below this.
http://open-pim.com/tmp/LazyList.zip
i think this example is great for build your custom ListView

Related

Expandable RecyclerView and custom ui

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. :)

View for a list of items that don't scroll, and handle on item click events by the item position

Just like a ListView but instead it doesn't scroll. Its content is added programatically via an ArrayAdapter. Is there any view that can be used for this purpose?
PS: Not LinearLayout, since it doesn't get its content from an adapter (I want the observer pattern)
Edit: Let me explain a little bit more. Suppose you need a list of items, but the list itself is not scrollable, what is scrollable is the screen.
That being said, the list of items should show ALL items, not a limited amount based on a fixed height. The way to go is LinearLayout as it is both non-scrollable and shows all items within itself.
But there is a third requierement. You don't want to add(View) directly, but instead, you want something similar to an ArrayAdapter so that you have a control of the items and their position, so you can handle on item click events based on their position. As far as I know, this can't be done using a LinearLayout. So my question is, does any view exist for this purpose?
You could try using a ListView, but disable scrolling, as described here
Put your layout inside a ScrollView and yes you have to use a Linearlayout. You need to set tag for each of your view that you add dynamically and whenever your view is clicked you can get it's position by view.getTag() and perform the required operation.
Note : Adding views at run time may affect performance.

Is possible refresh a item from a ListView without refresh entire list?

I have a listview with many items(10 - 200 approx.), when I click on an item, I update its attributes and then update the listview. But as many items the update is a bit slow.
Is there anyway to only update an item in a listview without having to refresh the entire list?
Regards
It is possible to change an element of a ListView, but it is not a good solution, because you are accessing a widget of your listview item directly e.g. textview. But it at least can be used as a temporary solution
Example:
How can I update a single row in a ListView?

Extended list view: Show text input inside once clicked

I am working on a UI where I have a list view. Each row has 2 information. One is Product name and the other is product ID stacked one over other. So each row has 2 lines of data.
What i want to do with this:
Once a user clicks on each row, it will further expand and show one input and one spinner. So it is basically for putting in Quantity and unit of measure.
Please let me know if this is achievable and if I can refer to some example.
What I need is more like
Taskos To Do List | Task List
https://play.google.com/store/apps/details?id=com.taskos&hl=en
All i need is that the category will not be expandable. Only the items will be expandable. All i need is an example of such app and then I can take it forward.
I think it could be done... you would need to put the extra widgets in your row layout, populate them and hide them upon list creation, then in your onListItemCLick you could unhide them.
Note I have no idea if this would work, but it seems reasonable that it might and it's what I would try and do to achieve the goal.
listView cannot be expanded. however you can use an expandablelistView
But the kind of functionality you want cannot be done this way(I guess.).
You can use
registerForContextMenu("your list View");
to register your list view
onCreateContextMenu
for the kind of action you want to be performed in your case its dialog with EditText and Spinner to have input from user

How can I "set View" in right place where I remove an item in ListView (Android)

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.

Categories

Resources