=0){result+=f.getPath()+"";}}if(result.equals(""))result="找不到文件!!";returnresult;-IMDN开发者社群-imdn.cn"> =0){result+=f.getPath()+"";}}if(result.equals(""))result="找不到文件!!";returnresult; - IMDN开发者社群-imdn.cn">
登录
首页 » Android » Android indexOf搜索文件示例

Android indexOf搜索文件示例

于 2023-07-23 发布 文件大小:7.60 kB
0 25
下载积分: 2 下载次数: 1

代码说明:

Android 系统中搜索文件的一个简单例子,功能和Windows搜索文件相似,不过实现上就差别大了:先载入main.xml Layout ,初始化对象:   mKeyword=(EditText)findViewById(R.id.mKeyword);   mButton=(Button)findViewById(R.id.mButton);   mResult=(TextView) findViewById(R.id.mResult);   然后定义一个方法,将mButton添加onClickListener,取得输入的关键字,再创建搜索文件的method:   private String searchFile(String keyword)   {    String result="";    File[] files=new File("/").listFiles();    for( File f : files )    {    if(f.getName().indexOf(keyword)>=0)    {    result+=f.getPath()+" ";    }    }    if(result.equals("")) result="找不到文件!!";    return result;

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • Android实现切水果游戏源码
    本程序为用Android实现的切水果游戏,代码里有详细注释,游戏过程为不断出现上抛的水果,然后游戏者手指在界面上滑动,出现类似于切的效果,每次切中后,游戏者都会获得相应积分
    2022-01-27 16:57:33下载
    积分:1
  • 一款基于安卓的简单聊天软件
    可以注册登录、发送文字表情。 使用前请安装好mysql。 this is a android instant messenger based on socket communication basic functionality: 1. a user can register an account with a username, his/her age and gender 2. login with username and password 3. find out friends by username or particulars(age and gender) 4. chat with a friend with text and emoji 5. chatting history available for checking 6. messages sent to offline friends will be saved at server and pushed to that friend when he/she signs in 7. ringtone and vibration notification when a message arrived if messanger is not foreground
    2022-06-26 00:25:43下载
    积分:1
  • ActivityAnimation
    android Activity间跳转动画,直接可用(android Activity jump between animations directly available)
    2013-09-04 11:06:05下载
    积分:1
  • 面试题精选
    一道经典的面试题,内容是Android+php相关测试
    2022-01-26 00:20:51下载
    积分:1
  • 安卓电子书
    电子书拥有书签字体转换等功能。背景色彩的修改
    2022-02-14 14:54:25下载
    积分:1
  • Android铃声设置模块源码
    Android铃声设置模块源码,通过本Andorid源码将了解以下相关技巧: 声明和取得TabHost对象、新建一个newTabSpec(newTabSpec)、设置其标签和图标(setIndicator)、设置内容(setContent)、情景模式设置、设置TabHost的背景图片资源、初始化,取得AudioManager、标签切换事件处理、RadioButton添加监听器、添加onChangeListener、RadioButton添加监听器、取得手机的初始音量,并初始化进度条、取得初始模式,并分别设置图标、增加和降低音量、静音和振动状态的实现、计算切换时间等。
    2022-05-19 16:54:28下载
    积分:1
  • 最全代码动画
    分享一下非常好的动画大全,非常适合想要完善android UI的广大  码友。
    2022-03-24 07:19:45下载
    积分:1
  • android 扫描二维码 并 生成二维码实例源码下载
    android 扫描二维码 并 生成二维码实例源码下载
    2015-03-26下载
    积分:1
  • UsbHostDemo
    主要是通过USB host 与HID设备进行通讯:枚举设备->找到设备的接口->连接设备->分配相应的端点->在IN端点进行读操作,在OUT端点进行写操作。 Mainly through the USB host to communicate with HID devices: enumerate devices-> find the device interface-> Connect device-> Assign appropriate endpoint-> the IN endpoint read, write in the OUT endpoint.
    2022-01-21 22:08:54下载
    积分:1
  • Android任务管理器源码
    高级任务管理器Advanced Task Manager帮你结束程序,加快运行速度,节约电量,功能包括自动结束程序服务、程序间切换、显示内存信息、排除列表、一件结束全部窗口小部件、快速卸载程序。
    2023-07-27 02:40:02下载
    积分:1
  • 696522资源总数
  • 104031会员总数
  • 39今日下载