I'm new to Android development.
I need to make a listview with text and icon audio player. The icon has three States, "download", "downloading", "play" and "pause". The idea is that when populating the listview, set the "download" icon if the track is not downloaded and "play" if the track is downloaded". If a person clicks the "download" button the icon should be updated to "downloading" to start the download, then when complete, you should see the icon "play". If the user presses the "play" icon for this element should be updated to "pause".
I can't change the icon . I tried to change them in onItemClickListener and make the onClick in the getView method in adapter, but when scrolling the icons changed to the old. And if you select multiple items in the list, then change all the icons, and I need to change only one, for playing of the track.
I didn't show the code because there is nothing that can be corrected. - all wrong
if you have your own adapter try using a method notifyDataSetChanged();
That is happening due to recycling of views. If you click on an item and you will see multiple items clicked.
Use RecyclerView instead of listView, which will handle recycling by its own and its ViewHolder class takes care of the issue you are having.
And don't forget to notify the recyclerView adapter whenever you make some change in data source (i.e. arraylist)
Check out this example...
Hope it helps
http://hmkcode.com/android-simple-recyclerview-widget-example/
Related
in the beginning i want to apologize for my bad english but im currently working on an application, i have 2 firebase tables (propertys and tennants) sorted by the logged user (doesn't even matter for my problem). So i have 2 possibilities in the navigation drawer, i can add and view propertys, view is enabled in the recyclerview, adding is done by fab button, both RV and fab are in an fragment, same goes with tennants. I can click on each of items and view all the details about them in an activity, so what i want is when i click on an property item and it opens activity where my property details are, i have a button that should add tennats to that specific property and list them in that activity (property details). You guys got any solution? I tried onClick of that button to open tennants recyclerview and select multiple items and then onBackPressed to try to save them but i simply cannot get it working, then i tried with alertCustomDialog where it should list all the tennants (part that iam not able to do) and with checkboxes select tenants that i want to, please if anyone can help or has some clue how to do this, please HELP! :=)
In my project I've setted the background color of my items (composed of several elements inserted in a ConstraintLayout) inside a ListView but the default animation of click and long click disappears if the background color is not at least a little transparent. In fact, as transparency decreases, the effect of clicking on the elements is less and less evident. In a few words, color goes to hide the animation if isn't transparent. How to solve this problem and then bring selection animation to the foreground?
Same problem, still unresolved: ListView items not showing tap animation
RESOLVED!
You have to simply add android:drawSelectorOnTop="true" in your ListView XML tag. In this way you can modify and customize the list item background and at the same time bring back the "selector" on top of the "z axis" of GUI. Yuhu!
If you are giving a background coloraturas to the list items then you might be hiding the system press animations. in this case you can use the methods like OnItemLongClickListener() and itemClickListener () and add your custom animations to the view.
Hi everyone.
I've come up with an idea for an Android App, and I was thinking how to turn my thoughts into something working. I know how to program for Android even though I'm not that advanced as you might see, so I wanted some tips from you guys who I'm sure will be able to help.
Idea
I was thinking about an App to organize stuff, see your objects on a list and be able to add, move or remove them from the list.
Thoughts
I first thought I needed a RecyclerViewto display each item. Then I thought every item itself might be a box, and so be containing other items inside: this brought me to think of a sort of "nested" system of RecyclerViews. Before going too deep into this system I had to clarify each item should have been a Class, each of which should have had a RecyclerView assigned.
Question
I was wondering how I could make this "nested" system of RecyclerViews. I thought about making a RecyclerView an object, because I need each RecyclerView to display, function and be always the same in any screen of any item. But I don't know what the best way is.
Should I make it an object? How do I create a new RecyclerView through a button so the user can first tap an item and then, eventually, tap a button (inside the item details view for instance) to make it a box item and so create and open a RecyclerView when tapped?
P.S.
It may seem like multiple questions but it actually is only one: how to add and display a RecycerView when I tap a button inside a details screen of an item, of course automatically (have a reference to that RecyclerView).
You have to create the RecyclerView that holds your items list, let's call it rv_list, this RecyclerView has an adapter that takes each item and adapts it to an xml layout row_item.xml that you should define. Now to make an item itself display its own recyclerview you should put a recyclerview inside row_item.xml and populate it when adapting that item to rv_list inside the method onBindViewHolder.
Below is a picture of my app, I am currently using a modified version of this app to show my expandable content. Now my problem is with my ImageView, I currently have 3 layouts, one for the main dialog (with listview), one for the listview title & arrow and one for the item details (item row once expanded). I want to add animation to the ImageView so when you click the image or title textview, the list will expand and animate the change. How can I do this? I cannot get the onClick to work because it doesn't know there are 2 imageviews, it seens only one...
I will assume that your ImageView is this arrow inside your ListView element (because you didn't write it clearly enough).
You probably shouldnt try to attach onClickListener to your ImageView at all (nor to your ListView element title). The good way of implementing what you want you achieve would be to use ListView's onItemClickListener to detect clicks performed on specific items inside your listview, and then expanding appropriate expandable content.
When I place a CheckBox in the row layout for a ListView, I am no longer able to recieve OnItemClick and OnItemLongClick events. On the other hand, using CheckedTextView allows these events to go through, but I don't know how to automate clicking on them in my JUnit/Robotium tests. Does anyone have any suggestions about what I can do to get the best of both worlds here?
You can make OnItem(Long)Click work if you set up the CheckBox views to non-focusable (i.e. setFocusable(false) and setFocusableInTouchMode(false), or their xml equivalents).
Note: The listeners will fire as long as you tap outside the checkbox itself. Tapping on the checkbox will toggle it only (but I guess this is what you would want).