Android 文件管理器的列表界面

这篇博客介绍了如何在Android应用中创建一个带有详细信息的文件管理器列表,包括文件名、图标、大小、权限和修改日期。作者使用RecyclerView实现,并提供了关键代码片段,特别是如何计算文件和文件夹大小,以及根据文件类型设置图标。文章还提及了获取文件修改时间的方法,并提到多线程在计算文件大小中的应用,以提高性能。
摘要由CSDN通过智能技术生成

前言:

之前做了一个文件管理器的app,那么列表中只有名字....实在太简陋了,所以我打算做一个比较好看一点的列表。

效果图:


可能对于专业的你来说,还是比较简陋。这次列表中,除了文件名,我还添加了图标,文件大小,文件权限还有修改日期。

首先这是一个RecyclerView..然后先上代码,这个RecyclerView的部分代码

<?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"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/myFileImage"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_margin="5dp"
        app:srcCompat="@mipmap/ic_launcher" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:id="@+id/myFileName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:singleLine="true"
            android:ellipsize="start"
            android:textSize="25sp"
            android:layout_gravity="center"
            android:text="TextView" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/fileSize"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="大小" />

            <TextView
                android:id="@+id/filePower"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="权限" />

            <TextView
                android:id="@+id/fileDate"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="创建日期" />
        </LinearLayout>
    </LinearLayout>


</LinearLayout>

这个是列表每个项目的样子,来张截图


<

  • 5
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值