在这里首先说明,此实例是我从csdn下载的一个例子研究解析并且重写的。
第一 我们先概述的描述的说明下,我们这个MP3播放器的具体表现形式,实现方法等。
我们实现的播放器是用tab页形式体现的,分别是具体的音乐列表tab,艺术家tab,专辑信息tab,最近播放信息tab,还有一个具体的播放的tab界面。
如图所示 这是当前显示的四个主tab页面,还有一个具体的音乐播放界面:
如上图所示。
这是四个界面的具体显示情况。
此外 一下将贴出对应的每个界面的layout.xml文件
主布局文件
main.xml
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp" >
<!-- 注意:这里的id是@android下的id 不是@+id ,并且id必须为这个默认的id-->
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</TabWidget>
<!-- 注意:这里的id是@android下的id 不是@+id ,并且id必须为这个默认的id-->
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" >
</FrameLayout>
</LinearLayout>
</TabHost>
歌曲列表布局
listmusic.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/listbg"
android:orientation="vertical" >
<ListView
android:id="@+id/listAllMusic"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
艺术家列表布局
artist.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/listbg1"
android:orientation="vertical" >
<ListView
android:id="@+id/artistListView"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
专辑信息布局
albums.xml
<?xml version="1.0" encoding="utf-8"?