list view animation - android

I have a list view with custom adapter. I'm trying to implement following
when a item in the list is clicked, only that item is expanded and show some info.
when it is clicked again, it goes back to the first state. can any one suggest a
way to achieve this.
thanks in advance

Use ExpandableListView.
It can help you.
ExpandableListView can expanded and back to the first state.
Also, you can custom inner layout.(some info)
please use it.

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

Update View in Activity in response to recycler view item click

I have this type of activity layout
In my layout, the yellow portion is my recyclerview, which is currently working as the expandable list.
Now in my scenario, when the user clicks on any item in the recyclerview than the layout changes in the activity shown by, green area and its child in the image.
Is there any way to do so?
Here is the simple example of pass value from recyclerview to activity using eventbus. Try this maybe will help you to solve your problem.
You can use callback method.On click of item update UI using callback method.
Yes you can achieve this easily by using EventBus.

Change text of one specific context menu item

I've created a context menu for my recycler view items. In the menu I have Watch (like favourites), Share and Hide. Now what I want to do is get the specific position of the Recycler View and check if the Watch or Hide button has been pressed. How can I go about doing this? I've used a flag but that just checks the whole Recycler View so that doesn't work.
I can show source code on request too. I know it needs to go in my Adapter but can't figure out the position of it
Thanks in advance.
just add a boolean variable in your List to check whether to show Watch or Hide button.
use getAdapterPosition() method when user clicked the clicked on button and then use that position to update value in your model class.

Change imageview for selected item in listview

In my layout I have a button and a listview. How can I change the imageview of item I selected when the button is clicked. So lets say, I select 5 items, and after I click the button, images for those 5 items will be changed.
So I am confused what function I should use. Right now i used button.setOnClickListener but it seems wrong because only the very first item's imageview will be changed when button clicked. Should I use listview.setItemOnClickListener? Or is there any other way I can do this?
Thanks a lot!
Add a boolean to the data object in your adapter. Say you've got ArrayAdapter<MyDataObject>. Add some kind of "selected" field in the MyDataObject, and toggle it when you "select" the row.
Override getView in the adapter (you'll need a custom Adapter, btw. I'd just extend ArrayAdapter). When you render the row, if the "selected" field is true, show the "other" image.
When you click the button, call 'notifyDataSetChanged' on the adapter. The will cause the visible rows to refresh themselves (and call getView for each).
I think that'll work.
Since you only want images to change when you click the button, you'll need to have some kind of global boolean, so the getView won't show the image until the button has been clicked.
The complication here is, you have to deal with rows that may have been scrolled out of view, which don't have active views, but logically exist. It would be really hard to explain the concept here. I'd suggest some tutorials on ListView if you're not familiar with the recycling of row views.
You can used custom baseadapter for listview and setonclicklistener in the getView() method.... see tutorial here this is hope for help
You can use button click listener as well as on itemClickListener too but to make a image view in selected state in a list, you have to call setSelected method of imageview parent layout.
Please put a comment if you don't get me.
Thanks

Custom Listener for a ListView item

I have a View with a ListView appended, which actually uses a custom view item done programatically. Inside each list item I have a button which I need to track, to update another item in the view. It is only invalidated when you click on the list item button, not anywhere else in the list item.
So I thought of creating a custom Listener. I trigger it when the button is clicked, but I have no way to access it from the ListView activity.
Is there a way to simulate those setOnItem...Listener's using a custom listener? Thanks in advance
Please see this link to help with how to set onClickListener from within custom ListAdapters.
You can use the myButton.getTag() and myButton.setTag() to put and get data to/from your View/Button.
See this link as well to help with custom ListAdapters.
Here is another good example I found of how to use a custom adapter.

Categories

Resources