Пример #1
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    String itemStr = ((FileListAdapter.ViewHolder) v.getTag()).filename.getText().toString();
    final File file = new File(mCurrentDir, itemStr);

    if (file.isDirectory()) {
      // Open the file folder
      mCurrentDir = new File(mCurrentDir.getPath() + "/" + itemStr);
      updateListView();
      getListView().setSelection(0);
    } else {
      // SPRD: if sd card and internal storage is not avalible,show toast
      if (!Environment.getExternalStoragePathState().equals(Environment.MEDIA_MOUNTED)
          && !Environment.getInternalStoragePathState().equals(Environment.MEDIA_MOUNTED)) {
        Toast.makeText(getApplicationContext(), R.string.stroage_not_mounted, Toast.LENGTH_LONG)
            .show();
      } else {
        Intent intent = new Intent();
        intent.putExtra("path", file.getAbsolutePath());
        intent.putExtra("name", file.getName());
        setResult(RESULT_OK, intent);
      }
      finish();
    }
  }