这可能是一个愚蠢的问题。Android音乐播放器:如何显示歌曲标题
我有一个ListView的歌曲,当点击ListView中的一个项目时,我打开另一个意图来显示专辑封面。
的ListView:http://i.imgur.com/24s7Ema.png 球员:http://i.imgur.com/Rq5Ce7d.png
在第二意图“球员”我如何显示当前播放的歌曲名称名称存在。
SONG.XML
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:onClick="songPicked"
android:padding="5dp" >
<TextView
android:id="@+id/song_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#0000FF"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/song_artist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FF0000"
android:textSize="18sp" />
</LinearLayout>
SONGADAPTER.JAVA
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
//Map to song layout
LinearLayout songLay = (LinearLayout)songInf.inflate(R.layout.song, parent, false);
//get title and artist views
TextView songView = (TextView) songLay.findViewById(R.id.song_title);
TextView artistView = (TextView) songLay.findViewById(R.id.song_artist);
//get the correct Song instance using current position index
Song currSong = songs.get(position);
//get title and artist strings (Mapping the strings to views in song Layout file)
songView.setText(currSong.getTitle());
artistView.setText(currSong.getArtist());
//set the position as tag (play the correct song when clicking an item in the list)
songLay.setTag(position);
/*song.xml has an onClick attribute, the method is used to retrieve the tag in the activity*/
return songLay;
}
MUSICPLAYER.JAVA(FIRST LISTVIEW)
public void songPicked(View view)
{
/*Song position (item in list view) has been set as Tag in SongAdapter*/
musicSrv.setSong(Integer.parseInt(view.getTag().toString())); //retrieve position and pass to Service instance
/*Starting the NowPlaying activity*/
Intent in = new Intent(getApplicationContext(), NowPlaying.class);
setResult(100,in);
startActivity(in);
musicSrv.playSong();
}
NOWPLAYING.JAVA(NEW意图播放器控制)
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if(resultCode==100)
{
//Code here
}
}
显示您的代码。因为它太愚蠢的问题。 – Piyush 2014-09-27 04:48:30
这是我的项目:http://www.filedropper.com/musicplayer。这有帮助吗?是尴尬,这是一个愚蠢的问题。但是谢谢你试图帮助我。 – jackuars 2014-09-27 05:07:09
伴侣,我不需要整个项目我只想要你的'意图'的相关代码。 – Piyush 2014-09-27 05:09:54