Concern about listview in android - android

I am developing music application for android. I am done with most of the parts but i need help for Listview .
Suppose that user selects a song from list in Main and then it goes to new activity to play that song. In new activity user has option for next button to play next song . Now when user clicks next button 10 times and consider current playing song is XYZ. when user come back to main activity i want to highlight that song XYZ from list and display it on top of screen from list.
Please advise how to show that song on top in listview. I am able to find the position of XYZ from list but don't know how to highlight it and display it on top in current list.
Hope i made myself clear about this whole.
thanks in advance.

i would suggest that when you enter the new activity of playing the song you save the position of the song in your case XYZ.
so now when you go back use that value and pass it to your intent. and in your main activity u get the value so set the postion of the listview.
lv.smoothScrollToPosition(position);
Hope this helps you

Have you considered adding a header and then is there is a selected song you add that song as the header if there is no selected song you set header visibility to GONE.

You face 2 problems:
Hight light the row at selected song:
You can try set background at the selected song view to hight light it.
Show the playing song at the top of the ListView.
About show to top ListView. You can use ListView.addHeader... to add playing song view to top view.
Hope you solve it

Related

android reach next and previous item of listview

I have a listView that filled by custom Adapter and listed some sounds from external storage.
when user click on each item of listView a custom alerDialog pop-up and it has play, next and previous buttons.
The problem is I have no idea how to reach information of next and previous sound in listView to play them in this alertDialog without closing it?(in other words I want to reach information of my listView from another class(alertDialog)) Thanks for help.

In listview changing background of button in rows on click of button in one row

I have a listview with play button to play songs in each row. When i click on play button its background changes to pause button. What i want is when I click on play button in one row, the button that has background set to pause image on previous click should automatically change to play image and only the button which I has clicked should have pause background.
On click of button in a row of listview how to change other rows buttons background?
Regards,
Naresh T
I'll give you the basic idea of how you could implement this. You need to have a custom Adapter which would store the View which is currently set to "playing" state. Let's say, it would be called mCurPlaying. After the user clicks another View, change the background of the mCurPlaying and replace it with the newly clicked View.
Should you have any problems with implementing this, please, drop a note and I'll give you some more hints in code.
Instead of writing on click for whole row set only onclick for a button in that row in getview method of adapter class it solved your problem.

Android Listview item UI change

I have a listview, each item in listview have a button.
I set a onClickListener to the button to play music.
Each time, only "ONE MUSIC" can be played!!!
But so far, I haven't implemented the play music part, I just handle the UI change first.
When I click the button,
1) The "play" image of the button will change to "stop".
2) If the music is already playing, it will stop the previous song(and change the UI of corresponding listview item image to "stop"), and then play the selected song(and change the UI of corresponding listview item image to "play).
Now I faced some problems and don't know how to fix it.
Q1) When one song is playing, and I scroll the listview up and down, the "stop" image will change back to "play", so the user don't know which item is playing.
Q2) This is the hardest problem!!
When one song is already playing, and user click another song, I don't know how to notify the previous listview item to change the UI from "song" to "play"(since the previous music will stop).

Android auto scroll activity content on long press

I am newbie to android my activity implemented a drag and drop in list view but when my list is full its not displaying last record on the screen as length of the list record is bigger then screen size .. so when I tried to drag and drop my first record at the end of the list
I can select first record but I cant scroll down to the last record .. I need to implement when I select my first record and drag it toward down list ll automatically scroll down toward end of the list and vice versa hope I make some thing clear to you .. if still there is any ambiguity let me know
Thank
Try to use listview.smoothScrollToPosition(position) inside your drag and drop function. Define the position of dragged element and if needed use smoothScrollToPosition method.

I want to put the media player with each row of listView?

I want to put the media player with each row of listView, can any one of you help me in making it....actually its coming in front of my Screen but I want it with the every row of the ListView to Play and pause with all functionality so can any one of you help me in this??

Categories

Resources