日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > 綜合技術 > Android--快速地搜索手機文件引擎小程序(File I/O)

Android--快速地搜索手機文件引擎小程序(File I/O)

來源:程序員人生   發布時間:2015-04-08 08:57:29 閱讀次數:3202次

main.xml代碼以下:

<?xml version="1.0" encoding="utf⑻"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TableRow> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="請輸入要搜索的關鍵字:" /> <EditText android:id="@+id/edit" android:layout_width="120px" android:layout_height="wrap_content" /> </TableRow> </TableLayout> <Button android:id="@+id/btn_search" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="搜索" /> <TextView android:id="@+id/info" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout>
.java程序以下:

package org.lxh.demo; import java.io.File; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnFocusChangeListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class Hello extends Activity { private Button search = null; private TextView info = null; private EditText edit = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 生命周期方法 super.setContentView(R.layout.main); // 設置要使用的布局管理器 this.edit = (EditText) super.findViewById(R.id.edit); this.info = (TextView) super.findViewById(R.id.info); this.search = (Button) super.findViewById(R.id.btn_search); this.search.setOnClickListener(new OnClick()); } private class OnClick implements OnClickListener { public void onClick(View arg0) { String keyWords = Hello.this.edit.getText().toString(); if (keyWords.equals("")) { Hello.this.info.setText("請輸入關鍵字!"); } else { Hello.this.info.setText(searchFile(keyWords)); } } private CharSequence searchFile(String keyWords) { String result = ""; File[] files = new File("/").listFiles();//獲得所有文件 for (File f : files) { if (f.getName().indexOf(keyWords) >= 0) {//文件名匹配 result += f.getPath() + " "; } } if (result.equals("")) { result = "找不到文件!"; } return result; } } }

運行以下:



生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 精品伦精品一区二区三区视频 | 国产午夜精品视频 | 欧美精品v国产精品v日韩精品 | 一二三区在线 | 精品久| 成人在线黄色电影 | 91久久精品国产 | 国产精品29页| 亚洲免费小视频 | 国产日韩精品在线 | 日韩一区二区三区四区五区 | 国产激情在线观看 | 亚洲精品v天堂中文字幕 | 亚洲一区在线观看视频 | 亚洲精品66| 丰满岳乱妇一区二区三区 | 国产精品v亚洲精品v日韩精品 | 久久久久亚洲一区二区三区 | 久久久穴 | 久久99精品久久久久久久久久久久 | 18成人在线观看 | 亚洲污视频 | 99精品电影 | 久久九九| 一区二区三区国产在线 | 亚洲欧美日韩另类精品一区二区三区 | 精品成人在线视频 | 成人在线一区二区三区 | 中文字幕国产日韩 | 成人在线网站 | 91精品国产99久久久久久红楼 | 最新国产精品视频 | 欧美人体一区二区三区 | 毛片精品| 国产精品成av人在线视午夜片 | 国产一区二区精品 | 久久亚洲精品国产日韩潮高 | 中文字幕日本在线 | 国产在线一区二区三区 | 国产精品日本一区二区不卡视频 | 久久不卡 |