首页| JavaScript| HTML/CSS| Matlab| PHP| Python| Java| C/C++/VC++| C#| ASP| 其他|
购买积分 购买会员 激活码充值

您现在的位置是:虫虫源码 > Java > Android indexOf搜索文件示例

Android indexOf搜索文件示例

  • 资源大小:7.60 kB
  • 上传时间:2021-06-30
  • 下载次数:0次
  • 浏览次数:0次
  • 资源积分:1积分
  • 标      签: Android

资 源 简 介

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;

文 件 列 表

codesc.net
sousuo
.project
sousuo
sousuo
.classpath
codesc.net
VIP VIP
  • 大智若愚 5小时前 成为了本站会员

  • Mason 8小时前 成为了本站会员

  • 8小时前 成为了本站会员

  • Half_Punch 1天前 成为了本站会员

  • liqing71718 1天前 成为了本站会员

  • 伟国 1天前 成为了本站会员

  • songy 1天前 成为了本站会员

  • 纯色幽默 1天前 成为了本站会员

  • odd? 1天前 成为了本站会员

  • 52JOY... 1天前 成为了本站会员

0.177239s