Android 获取本地音频文件 并用ListView展示

效果丑了点,就这意思了(如果你也吹周董,那我们就是朋友)

整体思路,通过contentResolver.query 方法获取音频的信息

先看简单的xml

activity_main.xml,就一个ListView

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <ListView
        android:id="@+id/lv"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </ListView>
    
</LinearLayout>

music_list_iteam.xml,


版权声明:本文为weixin_41599636原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。