這可能是一個愚蠢的問題。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