Пример #1
0
  public void onCreate() {
    setContentView(R.layout.searchresultpage);
    super.onCreate();
    final View lySearchMode = findViewById(R.id.lySearchMode);
    tvSearchNotify = (TextView) findViewById(R.id.tvSearchNotify);
    etValue = (EditText) findViewById(R.id.etSearchFileName);
    etValue.setOnFocusChangeListener(
        new OnFocusChangeListener() {
          @Override
          public void onFocusChange(View v, boolean hasFocus) {
            lySearchMode.setVisibility(View.GONE);
          }
        });
    etValue.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {

          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            lySearchMode.setVisibility(View.GONE);
            return false;
          }
        });
    btSearchMode = (Button) findViewById(R.id.btSearchMode);
    btSearchMode.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            if (lySearchMode.getVisibility() == View.GONE) {
              lySearchMode.setVisibility(View.VISIBLE);
            } else {
              lySearchMode.setVisibility(View.GONE);
            }
          }
        });
    btSearch = (Button) findViewById(R.id.btSearch);
    btSearch.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            if (etValue.length() > 0) {
              mFileListFilter.clear();
              fileAdapter.notifyDataSetChanged();
              btSearch.setEnabled(false);
              T.hideInputPad(etValue);
              param.setCaseSensitive(false);
              param.setPath(FileManager.getInstance().getCurrentPath());
              param.setHide(false);
              param.setSearchValue(etValue.getText().toString());
              param.setSubdirectory(true);
              SysEng.getInstance()
                  .addThreadEvent(
                      new LoadSearchFileEvent(v.getContext(), true, param, SearchResultPage.this));
            } else {
              Toast.makeText(m_act, "请输入要查询文件的名称", Toast.LENGTH_LONG).show();
            }
          }
        });

    Button btOptions = (Button) findViewById(R.id.btOptions);
    btOptions.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            new SearchFileDialog()
                .Show(
                    m_act,
                    FileManager.getInstance().getCurrentPath(),
                    param,
                    SearchResultPage.this);
          }
        });

    btnBack = (Button) findViewById(R.id.btBack);
    btnBack.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            backKey();
          }
        });

    lvSearchMode = (ListView) findViewById(R.id.lvSearchMode);
    ArrayList<Map<String, String>> data = new ArrayList<Map<String, String>>();
    HashMap<String, String> item;

    item = new HashMap<String, String>();
    item.put("Title", "搜索全部");
    data.add(item);

    item = new HashMap<String, String>();
    item.put("Title", "搜索音乐");
    data.add(item);
    item = new HashMap<String, String>();
    item.put("Title", "搜索视频");
    data.add(item);
    item = new HashMap<String, String>();
    item.put("Title", "搜索图片");
    data.add(item);
    item = new HashMap<String, String>();
    item.put("Title", "搜索文档");
    data.add(item);
    item = new HashMap<String, String>();
    item.put("Title", "搜索安装包");
    data.add(item);
    item = new HashMap<String, String>();
    item.put("Title", "搜索压缩包");
    data.add(item);

    final SimpleAdapter modeAdapter =
        new SimpleAdapter(
            getContext(),
            data,
            R.layout.listitem_searchmode,
            new String[] {"Title"},
            new int[] {R.id.tvTitle});

    lvSearchMode.setAdapter(modeAdapter);
    lvSearchMode.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Map<String, String> item = (Map<String, String>) modeAdapter.getItem(position);
            btSearchMode.setText(item.get("Title").substring(2));
            param.setSearchType(position);
            lySearchMode.setVisibility(View.GONE);
            ResultFilter();
          }
        });

    lySearchMode.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            lySearchMode.setVisibility(View.GONE);
          }
        });

    m_locallist = (ListView) findViewById(R.id.lvLocallist);
    fileAdapter = new FavorFileAdapter(m_act, 1, mFileListFilter);
    m_locallist.setAdapter(fileAdapter);
    m_locallist.setOnScrollListener(m_localOnScrollListener);
    m_locallist.setOnItemClickListener(this);
    // if (mFileList.size() == 0)
    // {
    // new SearchFileDialog().Show(m_act, FileManager.GetHandler()
    // .getCurrentPath(), param, this);
    // }

    String FileName = m_act.getString(R.string.FavoriteType);
    String Data = new String(T.ReadResourceAssetsFile(m_act, FileName));
    FavoriteGroupParser mFavoriteParser = new FavoriteGroupParser();
    mGroupList.clear();
    ArrayList<FGroupInfo> result = mFavoriteParser.parseJokeByData(m_act, Data);
    mGroupList.addAll(result);

    Button btButton = (Button) findViewById(R.id.btCopy);
    btButton.setOnClickListener(this);

    btButton = (Button) findViewById(R.id.btCut);
    btButton.setOnClickListener(this);

    btButton = (Button) findViewById(R.id.btDelete);
    btButton.setOnClickListener(this);

    btButton = (Button) findViewById(R.id.btPaste);
    btButton.setOnClickListener(this);

    btButton = (Button) findViewById(R.id.btSelectAll);
    btButton.setOnClickListener(this);
  }