WEB开发网
开发学院手机开发Android 开发 Android 带ListView的音乐播放器 阅读

Android 带ListView的音乐播放器

 2010-09-06 08:19:00 来源:WEB开发网   
核心提示:带ListView的音乐播放器[功能]前篇写的是:通过文件名来播放视频 今天说的是:通过MediaStore 来得到目标的Uri 在把之传入MediaPlay 然后再播放所以 会有2个重点:* 列出emulator 的所有音乐文件* 音乐播放器[代码 步骤]1. 构建界面:main.xml写道1 Button 用于音乐

带ListView的音乐播放器

[功能]

前篇写的是:通过文件名来播放视频 今天说的是:通过MediaStore 来得到目标的Uri 在把之传入MediaPlay 然后再播放

所以 会有2个重点:

* 列出emulator 的所有音乐文件

* 音乐播放器

[代码 步骤]

1. 构建界面:main.xml

写道

1 Button 用于音乐播放控制(暂停/继续)

1 TextView 用于显示目标Uri

1 ListView 用于列出所有音乐文件

Java代码

< ?xml version="1.0" encoding="utf-8"?>

< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

>

< LinearLayout

android:orientation="horizontal"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

>

< Button

android:id="@+id/cmd"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Prepare"

/>

< TextView

android:id="@+id/name"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="NAME"

/>

< /LinearLayout>

< ListView

android:id="@+id/list"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

/>

< /LinearLayout>

< ?xml version="1.0" encoding="utf-8"?>

< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

>

< LinearLayout

android:orientation="horizontal"

1 2 3 4  下一页

Tags:Android ListView 音乐

编辑录入:coldstar [复制链接] [打 印]
赞助商链接