Android indexOf搜索文件示例.rar

时间:2022-07-30 06:26:19
【文件属性】:
文件名称:Android indexOf搜索文件示例.rar
文件大小:8KB
文件格式:RAR
更新时间:2022-07-30 06:26:19
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() "\n";    }    }    if(result.equals("")) result="找不到文件!!";    return result;
【文件预览】:
codesc.net
----sousuo()
--------res()
--------default.properties(384B)
--------gen()
--------src()
--------.project(842B)
--------.classpath(280B)
--------AndroidManifest.xml(629B)

网友评论