以前写过一篇简单的音乐播放器,但是这个播放器没有实现播放模式的切换,在项目中要实现两个播放模式,循环播放和随机播放,经过这两天的努力搞定了,界面比较粗糙。可以先看一下前面的简单音乐播放器,详细的就不说了,直接把代码放上去,详细的看前面的博文。
布局文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<Button
android:id="@+id/list1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="放松音乐"
android:textColor="#ffffff"
android:textSize="30sp"/>
<Button
android:id="@+id/list2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="冥想"
android:textColor="#ffffff"
android:textSize="30sp"/>
</LinearLayout>
<TextView
android:id="@+id/updatevedio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/linearlayout"
android:textSize="30sp"
android:textColor="#ffffff"
android:text="音乐列表"/>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/updatevedio"
android:id="@+id/lv">
</ListView>
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:maxEms="8"
android:singleLine="true"
android:ellipsize="marquee"
android:paddingBottom="20dp"
android:textSize="20sp"
android:textColor="#ffffff"/>
<LinearLayout
android:id="@+id/linearLayout"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height