android 简单的音乐播放器实现播放模式的切换

本文介绍了一个简单的Android音乐播放器,增加了播放模式切换功能,包括循环播放和随机播放。开发者通过这两天的工作成功实现了这一功能,并提供了相应的代码示例。尽管界面设计较为简单,但核心代码在之前的博文中已有详细讲解。
摘要由CSDN通过智能技术生成

以前写过一篇简单的音乐播放器,但是这个播放器没有实现播放模式的切换,在项目中要实现两个播放模式,循环播放和随机播放,经过这两天的努力搞定了,界面比较粗糙。可以先看一下前面的简单音乐播放器,详细的就不说了,直接把代码放上去,详细的看前面的博文。

布局文件

<?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
  • 4
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值