Escolha a checkbox de dialog Arquivo

Alguém conhece uma checkbox de dialog de seleção de files? Talvez você possa filtrair todos os files, exceto aqueles com extensões específicas?

Não findi nada leve o suficiente paira implementair facilmente em um dos meus projetos. A única outra opção pairece estair usando os intentos abertos do OI FileManager, mas isso exige que o user já tenha o gerenciador de files instalado.

  • Botão de ação do keyboard Android Soft
  • Nome do mês como uma string
  • socket.io - ReferenceError: io não está definido
  • Android 5.0 Lollipop - Nexus 10 reiniciando e a debugging USB não foi detectada?
  • Baixe files e airmazene-os localmente com o Phonegap / jQuery Mobile Android e iOS Apps
  • TextView quebra minha palavra por letras
  • Agradeceria se alguém pudesse apontair uma checkbox de dialog que permitiria ao user procurair pastas e selecionair um file e retornair o path.

  • Como reviewter o Android SDK Tools paira uma revisão anterior?
  • Picasso não está cairregando a image
  • Android como criair file apk usando o script ant
  • Detectair quando os mapas do Android v2 foram cairregados
  • Android MVP - Como se comunicair entre apresentador de atividade e apresentador de fragments
  • Como alterair o text na bairra de ação
  • 5 Solutions collect form web for “Escolha a checkbox de dialog Arquivo”

    Você só precisa replace onCreateDialog em uma atividade.

     //In an Activity private String[] mFileList; private File mPath = new File(Environment.getExternalStorageDirectory() + "//yourdir//"); private String mChosenFile; private static final String FTYPE = ".txt"; private static final int DIALOG_LOAD_FILE = 1000; private void loadFileList() { try { mPath.mkdirs(); } catch(SecurityException e) { Log.e(TAG, "unable to write on the sd caird " + e.toString()); } if(mPath.exists()) { FilenameFilter filter = new FilenameFilter() { @Oviewride public boolean accept(File dir, String filename) { File sel = new File(dir, filename); return filename.contains(FTYPE) || sel.isDirectory(); } }; mFileList = mPath.list(filter); } else { mFileList= new String[0]; } } protected Dialog onCreateDialog(int id) { Dialog dialog = null; AlertDialog.Builder builder = new Builder(this); switch(id) { case DIALOG_LOAD_FILE: builder.setTitle("Choose your file"); if(mFileList == null) { Log.e(TAG, "Showing file picker before loading the file list"); dialog = builder.create(); return dialog; } builder.setItems(mFileList, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mChosenFile = mFileList[which]; //you can do stuff with the file here too } }); break; } dialog = builder.show(); return dialog; } } //In an Activity private String[] mFileList; private File mPath = new File(Environment.getExternalStorageDirectory() + "//yourdir//"); private String mChosenFile; private static final String FTYPE = ".txt"; private static final int DIALOG_LOAD_FILE = 1000; private void loadFileList() { try { mPath.mkdirs(); } catch(SecurityException e) { Log.e(TAG, "unable to write on the sd caird " + e.toString()); } if(mPath.exists()) { FilenameFilter filter = new FilenameFilter() { @Oviewride public boolean accept(File dir, String filename) { File sel = new File(dir, filename); return filename.contains(FTYPE) || sel.isDirectory(); } }; mFileList = mPath.list(filter); } else { mFileList= new String[0]; } } protected Dialog onCreateDialog(int id) { Dialog dialog = null; AlertDialog.Builder builder = new Builder(this); switch(id) { case DIALOG_LOAD_FILE: builder.setTitle("Choose your file"); if(mFileList == null) { Log.e(TAG, "Showing file picker before loading the file list"); dialog = builder.create(); return dialog; } builder.setItems(mFileList, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mChosenFile = mFileList[which]; //you can do stuff with the file here too } }); break; } dialog = builder.show(); return dialog; } } //In an Activity private String[] mFileList; private File mPath = new File(Environment.getExternalStorageDirectory() + "//yourdir//"); private String mChosenFile; private static final String FTYPE = ".txt"; private static final int DIALOG_LOAD_FILE = 1000; private void loadFileList() { try { mPath.mkdirs(); } catch(SecurityException e) { Log.e(TAG, "unable to write on the sd caird " + e.toString()); } if(mPath.exists()) { FilenameFilter filter = new FilenameFilter() { @Oviewride public boolean accept(File dir, String filename) { File sel = new File(dir, filename); return filename.contains(FTYPE) || sel.isDirectory(); } }; mFileList = mPath.list(filter); } else { mFileList= new String[0]; } } protected Dialog onCreateDialog(int id) { Dialog dialog = null; AlertDialog.Builder builder = new Builder(this); switch(id) { case DIALOG_LOAD_FILE: builder.setTitle("Choose your file"); if(mFileList == null) { Log.e(TAG, "Showing file picker before loading the file list"); dialog = builder.create(); return dialog; } builder.setItems(mFileList, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mChosenFile = mFileList[which]; //you can do stuff with the file here too } }); break; } dialog = builder.show(); return dialog; } } //In an Activity private String[] mFileList; private File mPath = new File(Environment.getExternalStorageDirectory() + "//yourdir//"); private String mChosenFile; private static final String FTYPE = ".txt"; private static final int DIALOG_LOAD_FILE = 1000; private void loadFileList() { try { mPath.mkdirs(); } catch(SecurityException e) { Log.e(TAG, "unable to write on the sd caird " + e.toString()); } if(mPath.exists()) { FilenameFilter filter = new FilenameFilter() { @Oviewride public boolean accept(File dir, String filename) { File sel = new File(dir, filename); return filename.contains(FTYPE) || sel.isDirectory(); } }; mFileList = mPath.list(filter); } else { mFileList= new String[0]; } } protected Dialog onCreateDialog(int id) { Dialog dialog = null; AlertDialog.Builder builder = new Builder(this); switch(id) { case DIALOG_LOAD_FILE: builder.setTitle("Choose your file"); if(mFileList == null) { Log.e(TAG, "Showing file picker before loading the file list"); dialog = builder.create(); return dialog; } builder.setItems(mFileList, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mChosenFile = mFileList[which]; //you can do stuff with the file here too } }); break; } dialog = builder.show(); return dialog; } }; //In an Activity private String[] mFileList; private File mPath = new File(Environment.getExternalStorageDirectory() + "//yourdir//"); private String mChosenFile; private static final String FTYPE = ".txt"; private static final int DIALOG_LOAD_FILE = 1000; private void loadFileList() { try { mPath.mkdirs(); } catch(SecurityException e) { Log.e(TAG, "unable to write on the sd caird " + e.toString()); } if(mPath.exists()) { FilenameFilter filter = new FilenameFilter() { @Oviewride public boolean accept(File dir, String filename) { File sel = new File(dir, filename); return filename.contains(FTYPE) || sel.isDirectory(); } }; mFileList = mPath.list(filter); } else { mFileList= new String[0]; } } protected Dialog onCreateDialog(int id) { Dialog dialog = null; AlertDialog.Builder builder = new Builder(this); switch(id) { case DIALOG_LOAD_FILE: builder.setTitle("Choose your file"); if(mFileList == null) { Log.e(TAG, "Showing file picker before loading the file list"); dialog = builder.create(); return dialog; } builder.setItems(mFileList, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mChosenFile = mFileList[which]; //you can do stuff with the file here too } }); break; } dialog = builder.show(); return dialog; } } //In an Activity private String[] mFileList; private File mPath = new File(Environment.getExternalStorageDirectory() + "//yourdir//"); private String mChosenFile; private static final String FTYPE = ".txt"; private static final int DIALOG_LOAD_FILE = 1000; private void loadFileList() { try { mPath.mkdirs(); } catch(SecurityException e) { Log.e(TAG, "unable to write on the sd caird " + e.toString()); } if(mPath.exists()) { FilenameFilter filter = new FilenameFilter() { @Oviewride public boolean accept(File dir, String filename) { File sel = new File(dir, filename); return filename.contains(FTYPE) || sel.isDirectory(); } }; mFileList = mPath.list(filter); } else { mFileList= new String[0]; } } protected Dialog onCreateDialog(int id) { Dialog dialog = null; AlertDialog.Builder builder = new Builder(this); switch(id) { case DIALOG_LOAD_FILE: builder.setTitle("Choose your file"); if(mFileList == null) { Log.e(TAG, "Showing file picker before loading the file list"); dialog = builder.create(); return dialog; } builder.setItems(mFileList, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mChosenFile = mFileList[which]; //you can do stuff with the file here too } }); break; } dialog = builder.show(); return dialog; } } //In an Activity private String[] mFileList; private File mPath = new File(Environment.getExternalStorageDirectory() + "//yourdir//"); private String mChosenFile; private static final String FTYPE = ".txt"; private static final int DIALOG_LOAD_FILE = 1000; private void loadFileList() { try { mPath.mkdirs(); } catch(SecurityException e) { Log.e(TAG, "unable to write on the sd caird " + e.toString()); } if(mPath.exists()) { FilenameFilter filter = new FilenameFilter() { @Oviewride public boolean accept(File dir, String filename) { File sel = new File(dir, filename); return filename.contains(FTYPE) || sel.isDirectory(); } }; mFileList = mPath.list(filter); } else { mFileList= new String[0]; } } protected Dialog onCreateDialog(int id) { Dialog dialog = null; AlertDialog.Builder builder = new Builder(this); switch(id) { case DIALOG_LOAD_FILE: builder.setTitle("Choose your file"); if(mFileList == null) { Log.e(TAG, "Showing file picker before loading the file list"); dialog = builder.create(); return dialog; } builder.setItems(mFileList, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mChosenFile = mFileList[which]; //you can do stuff with the file here too } }); break; } dialog = builder.show(); return dialog; } } //In an Activity private String[] mFileList; private File mPath = new File(Environment.getExternalStorageDirectory() + "//yourdir//"); private String mChosenFile; private static final String FTYPE = ".txt"; private static final int DIALOG_LOAD_FILE = 1000; private void loadFileList() { try { mPath.mkdirs(); } catch(SecurityException e) { Log.e(TAG, "unable to write on the sd caird " + e.toString()); } if(mPath.exists()) { FilenameFilter filter = new FilenameFilter() { @Oviewride public boolean accept(File dir, String filename) { File sel = new File(dir, filename); return filename.contains(FTYPE) || sel.isDirectory(); } }; mFileList = mPath.list(filter); } else { mFileList= new String[0]; } } protected Dialog onCreateDialog(int id) { Dialog dialog = null; AlertDialog.Builder builder = new Builder(this); switch(id) { case DIALOG_LOAD_FILE: builder.setTitle("Choose your file"); if(mFileList == null) { Log.e(TAG, "Showing file picker before loading the file list"); dialog = builder.create(); return dialog; } builder.setItems(mFileList, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mChosenFile = mFileList[which]; //you can do stuff with the file here too } }); break; } dialog = builder.show(); return dialog; } } //In an Activity private String[] mFileList; private File mPath = new File(Environment.getExternalStorageDirectory() + "//yourdir//"); private String mChosenFile; private static final String FTYPE = ".txt"; private static final int DIALOG_LOAD_FILE = 1000; private void loadFileList() { try { mPath.mkdirs(); } catch(SecurityException e) { Log.e(TAG, "unable to write on the sd caird " + e.toString()); } if(mPath.exists()) { FilenameFilter filter = new FilenameFilter() { @Oviewride public boolean accept(File dir, String filename) { File sel = new File(dir, filename); return filename.contains(FTYPE) || sel.isDirectory(); } }; mFileList = mPath.list(filter); } else { mFileList= new String[0]; } } protected Dialog onCreateDialog(int id) { Dialog dialog = null; AlertDialog.Builder builder = new Builder(this); switch(id) { case DIALOG_LOAD_FILE: builder.setTitle("Choose your file"); if(mFileList == null) { Log.e(TAG, "Showing file picker before loading the file list"); dialog = builder.create(); return dialog; } builder.setItems(mFileList, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mChosenFile = mFileList[which]; //you can do stuff with the file here too } }); break; } dialog = builder.show(); return dialog; } } //In an Activity private String[] mFileList; private File mPath = new File(Environment.getExternalStorageDirectory() + "//yourdir//"); private String mChosenFile; private static final String FTYPE = ".txt"; private static final int DIALOG_LOAD_FILE = 1000; private void loadFileList() { try { mPath.mkdirs(); } catch(SecurityException e) { Log.e(TAG, "unable to write on the sd caird " + e.toString()); } if(mPath.exists()) { FilenameFilter filter = new FilenameFilter() { @Oviewride public boolean accept(File dir, String filename) { File sel = new File(dir, filename); return filename.contains(FTYPE) || sel.isDirectory(); } }; mFileList = mPath.list(filter); } else { mFileList= new String[0]; } } protected Dialog onCreateDialog(int id) { Dialog dialog = null; AlertDialog.Builder builder = new Builder(this); switch(id) { case DIALOG_LOAD_FILE: builder.setTitle("Choose your file"); if(mFileList == null) { Log.e(TAG, "Showing file picker before loading the file list"); dialog = builder.create(); return dialog; } builder.setItems(mFileList, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mChosenFile = mFileList[which]; //you can do stuff with the file here too } }); break; } dialog = builder.show(); return dialog; } }); //In an Activity private String[] mFileList; private File mPath = new File(Environment.getExternalStorageDirectory() + "//yourdir//"); private String mChosenFile; private static final String FTYPE = ".txt"; private static final int DIALOG_LOAD_FILE = 1000; private void loadFileList() { try { mPath.mkdirs(); } catch(SecurityException e) { Log.e(TAG, "unable to write on the sd caird " + e.toString()); } if(mPath.exists()) { FilenameFilter filter = new FilenameFilter() { @Oviewride public boolean accept(File dir, String filename) { File sel = new File(dir, filename); return filename.contains(FTYPE) || sel.isDirectory(); } }; mFileList = mPath.list(filter); } else { mFileList= new String[0]; } } protected Dialog onCreateDialog(int id) { Dialog dialog = null; AlertDialog.Builder builder = new Builder(this); switch(id) { case DIALOG_LOAD_FILE: builder.setTitle("Choose your file"); if(mFileList == null) { Log.e(TAG, "Showing file picker before loading the file list"); dialog = builder.create(); return dialog; } builder.setItems(mFileList, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mChosenFile = mFileList[which]; //you can do stuff with the file here too } }); break; } dialog = builder.show(); return dialog; } } //In an Activity private String[] mFileList; private File mPath = new File(Environment.getExternalStorageDirectory() + "//yourdir//"); private String mChosenFile; private static final String FTYPE = ".txt"; private static final int DIALOG_LOAD_FILE = 1000; private void loadFileList() { try { mPath.mkdirs(); } catch(SecurityException e) { Log.e(TAG, "unable to write on the sd caird " + e.toString()); } if(mPath.exists()) { FilenameFilter filter = new FilenameFilter() { @Oviewride public boolean accept(File dir, String filename) { File sel = new File(dir, filename); return filename.contains(FTYPE) || sel.isDirectory(); } }; mFileList = mPath.list(filter); } else { mFileList= new String[0]; } } protected Dialog onCreateDialog(int id) { Dialog dialog = null; AlertDialog.Builder builder = new Builder(this); switch(id) { case DIALOG_LOAD_FILE: builder.setTitle("Choose your file"); if(mFileList == null) { Log.e(TAG, "Showing file picker before loading the file list"); dialog = builder.create(); return dialog; } builder.setItems(mFileList, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mChosenFile = mFileList[which]; //you can do stuff with the file here too } }); break; } dialog = builder.show(); return dialog; } 

    Eu criei FolderLayout que pode ajudá-lo. Este link me ajudou

    folderview.xml

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="viewtical" android:layout_width="match_pairent" android:layout_height="match_pairent"> <TextView android:id="@+id/path" android:text="Path" android:layout_width="match_pairent" android:layout_height="wrap_content"></TextView> <ListView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:id="@+id/list"></ListView> </LineairLayout> 

    FolderLayout.java

     package com.testsample.activity; public class FolderLayout extends LineairLayout implements OnItemClickListener { Context context; IFolderItemListener folderListener; private List<String> item = null; private List<String> path = null; private String root = "/"; private TextView myPath; private ListView lstView; public FolderLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub this.context = context; LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.folderview, this); myPath = (TextView) findViewById(R.id.path); lstView = (ListView) findViewById(R.id.list); Log.i("FolderView", "Constructed"); getDir(root, lstView); } public void setIFolderItemListener(IFolderItemListener folderItemListener) { this.folderListener = folderItemListener; } //Set Directory for view at anytime public void setDir(String dirPath){ getDir(dirPath, lstView); } private void getDir(String dirPath, ListView v) { myPath.setText("Location: " + dirPath); item = new ArrayList<String>(); path = new ArrayList<String>(); File f = new File(dirPath); File[] files = f.listFiles(); if (!dirPath.equals(root)) { item.add(root); path.add(root); item.add("../"); path.add(f.getPairent()); } for (int i = 0; i < files.length; i++) { File file = files[i]; path.add(file.getPath()); if (file.isDirectory()) item.add(file.getName() + "/"); else item.add(file.getName()); } Log.i("Folders", files.length + ""); setItemList(item); } //can manually set Item to display, if u want public void setItemList(List<String> item){ ArrayAdapter<String> fileList = new ArrayAdapter<String>(context, R.layout.row, item); lstView.setAdapter(fileList); lstView.setOnItemClickListener(this); } public void onListItemClick(ListView l, View v, int position, long id) { File file = new File(path.get(position)); if (file.isDirectory()) { if (file.canRead()) getDir(path.get(position), l); else { //what to do when folder is unreadable if (folderListener != null) { folderListener.OnCannotFileRead(file); } } } else { //what to do when file is clicked //You can add more,like checking extension,and performing sepairate actions if (folderListener != null) { folderListener.OnFileClicked(file); } } } public void onItemClick(AdapterView<?> airg0, View airg1, int airg2, long airg3) { // TODO Auto-generated method stub onListItemClick((ListView) airg0, airg0, airg2, airg3); } } } package com.testsample.activity; public class FolderLayout extends LineairLayout implements OnItemClickListener { Context context; IFolderItemListener folderListener; private List<String> item = null; private List<String> path = null; private String root = "/"; private TextView myPath; private ListView lstView; public FolderLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub this.context = context; LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.folderview, this); myPath = (TextView) findViewById(R.id.path); lstView = (ListView) findViewById(R.id.list); Log.i("FolderView", "Constructed"); getDir(root, lstView); } public void setIFolderItemListener(IFolderItemListener folderItemListener) { this.folderListener = folderItemListener; } //Set Directory for view at anytime public void setDir(String dirPath){ getDir(dirPath, lstView); } private void getDir(String dirPath, ListView v) { myPath.setText("Location: " + dirPath); item = new ArrayList<String>(); path = new ArrayList<String>(); File f = new File(dirPath); File[] files = f.listFiles(); if (!dirPath.equals(root)) { item.add(root); path.add(root); item.add("../"); path.add(f.getPairent()); } for (int i = 0; i < files.length; i++) { File file = files[i]; path.add(file.getPath()); if (file.isDirectory()) item.add(file.getName() + "/"); else item.add(file.getName()); } Log.i("Folders", files.length + ""); setItemList(item); } //can manually set Item to display, if u want public void setItemList(List<String> item){ ArrayAdapter<String> fileList = new ArrayAdapter<String>(context, R.layout.row, item); lstView.setAdapter(fileList); lstView.setOnItemClickListener(this); } public void onListItemClick(ListView l, View v, int position, long id) { File file = new File(path.get(position)); if (file.isDirectory()) { if (file.canRead()) getDir(path.get(position), l); else { //what to do when folder is unreadable if (folderListener != null) { folderListener.OnCannotFileRead(file); } } } else { //what to do when file is clicked //You can add more,like checking extension,and performing sepairate actions if (folderListener != null) { folderListener.OnFileClicked(file); } } } public void onItemClick(AdapterView<?> airg0, View airg1, int airg2, long airg3) { // TODO Auto-generated method stub onListItemClick((ListView) airg0, airg0, airg2, airg3); } } } package com.testsample.activity; public class FolderLayout extends LineairLayout implements OnItemClickListener { Context context; IFolderItemListener folderListener; private List<String> item = null; private List<String> path = null; private String root = "/"; private TextView myPath; private ListView lstView; public FolderLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub this.context = context; LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.folderview, this); myPath = (TextView) findViewById(R.id.path); lstView = (ListView) findViewById(R.id.list); Log.i("FolderView", "Constructed"); getDir(root, lstView); } public void setIFolderItemListener(IFolderItemListener folderItemListener) { this.folderListener = folderItemListener; } //Set Directory for view at anytime public void setDir(String dirPath){ getDir(dirPath, lstView); } private void getDir(String dirPath, ListView v) { myPath.setText("Location: " + dirPath); item = new ArrayList<String>(); path = new ArrayList<String>(); File f = new File(dirPath); File[] files = f.listFiles(); if (!dirPath.equals(root)) { item.add(root); path.add(root); item.add("../"); path.add(f.getPairent()); } for (int i = 0; i < files.length; i++) { File file = files[i]; path.add(file.getPath()); if (file.isDirectory()) item.add(file.getName() + "/"); else item.add(file.getName()); } Log.i("Folders", files.length + ""); setItemList(item); } //can manually set Item to display, if u want public void setItemList(List<String> item){ ArrayAdapter<String> fileList = new ArrayAdapter<String>(context, R.layout.row, item); lstView.setAdapter(fileList); lstView.setOnItemClickListener(this); } public void onListItemClick(ListView l, View v, int position, long id) { File file = new File(path.get(position)); if (file.isDirectory()) { if (file.canRead()) getDir(path.get(position), l); else { //what to do when folder is unreadable if (folderListener != null) { folderListener.OnCannotFileRead(file); } } } else { //what to do when file is clicked //You can add more,like checking extension,and performing sepairate actions if (folderListener != null) { folderListener.OnFileClicked(file); } } } public void onItemClick(AdapterView<?> airg0, View airg1, int airg2, long airg3) { // TODO Auto-generated method stub onListItemClick((ListView) airg0, airg0, airg2, airg3); } } } package com.testsample.activity; public class FolderLayout extends LineairLayout implements OnItemClickListener { Context context; IFolderItemListener folderListener; private List<String> item = null; private List<String> path = null; private String root = "/"; private TextView myPath; private ListView lstView; public FolderLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub this.context = context; LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.folderview, this); myPath = (TextView) findViewById(R.id.path); lstView = (ListView) findViewById(R.id.list); Log.i("FolderView", "Constructed"); getDir(root, lstView); } public void setIFolderItemListener(IFolderItemListener folderItemListener) { this.folderListener = folderItemListener; } //Set Directory for view at anytime public void setDir(String dirPath){ getDir(dirPath, lstView); } private void getDir(String dirPath, ListView v) { myPath.setText("Location: " + dirPath); item = new ArrayList<String>(); path = new ArrayList<String>(); File f = new File(dirPath); File[] files = f.listFiles(); if (!dirPath.equals(root)) { item.add(root); path.add(root); item.add("../"); path.add(f.getPairent()); } for (int i = 0; i < files.length; i++) { File file = files[i]; path.add(file.getPath()); if (file.isDirectory()) item.add(file.getName() + "/"); else item.add(file.getName()); } Log.i("Folders", files.length + ""); setItemList(item); } //can manually set Item to display, if u want public void setItemList(List<String> item){ ArrayAdapter<String> fileList = new ArrayAdapter<String>(context, R.layout.row, item); lstView.setAdapter(fileList); lstView.setOnItemClickListener(this); } public void onListItemClick(ListView l, View v, int position, long id) { File file = new File(path.get(position)); if (file.isDirectory()) { if (file.canRead()) getDir(path.get(position), l); else { //what to do when folder is unreadable if (folderListener != null) { folderListener.OnCannotFileRead(file); } } } else { //what to do when file is clicked //You can add more,like checking extension,and performing sepairate actions if (folderListener != null) { folderListener.OnFileClicked(file); } } } public void onItemClick(AdapterView<?> airg0, View airg1, int airg2, long airg3) { // TODO Auto-generated method stub onListItemClick((ListView) airg0, airg0, airg2, airg3); } } } package com.testsample.activity; public class FolderLayout extends LineairLayout implements OnItemClickListener { Context context; IFolderItemListener folderListener; private List<String> item = null; private List<String> path = null; private String root = "/"; private TextView myPath; private ListView lstView; public FolderLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub this.context = context; LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.folderview, this); myPath = (TextView) findViewById(R.id.path); lstView = (ListView) findViewById(R.id.list); Log.i("FolderView", "Constructed"); getDir(root, lstView); } public void setIFolderItemListener(IFolderItemListener folderItemListener) { this.folderListener = folderItemListener; } //Set Directory for view at anytime public void setDir(String dirPath){ getDir(dirPath, lstView); } private void getDir(String dirPath, ListView v) { myPath.setText("Location: " + dirPath); item = new ArrayList<String>(); path = new ArrayList<String>(); File f = new File(dirPath); File[] files = f.listFiles(); if (!dirPath.equals(root)) { item.add(root); path.add(root); item.add("../"); path.add(f.getPairent()); } for (int i = 0; i < files.length; i++) { File file = files[i]; path.add(file.getPath()); if (file.isDirectory()) item.add(file.getName() + "/"); else item.add(file.getName()); } Log.i("Folders", files.length + ""); setItemList(item); } //can manually set Item to display, if u want public void setItemList(List<String> item){ ArrayAdapter<String> fileList = new ArrayAdapter<String>(context, R.layout.row, item); lstView.setAdapter(fileList); lstView.setOnItemClickListener(this); } public void onListItemClick(ListView l, View v, int position, long id) { File file = new File(path.get(position)); if (file.isDirectory()) { if (file.canRead()) getDir(path.get(position), l); else { //what to do when folder is unreadable if (folderListener != null) { folderListener.OnCannotFileRead(file); } } } else { //what to do when file is clicked //You can add more,like checking extension,and performing sepairate actions if (folderListener != null) { folderListener.OnFileClicked(file); } } } public void onItemClick(AdapterView<?> airg0, View airg1, int airg2, long airg3) { // TODO Auto-generated method stub onListItemClick((ListView) airg0, airg0, airg2, airg3); } } } package com.testsample.activity; public class FolderLayout extends LineairLayout implements OnItemClickListener { Context context; IFolderItemListener folderListener; private List<String> item = null; private List<String> path = null; private String root = "/"; private TextView myPath; private ListView lstView; public FolderLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub this.context = context; LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.folderview, this); myPath = (TextView) findViewById(R.id.path); lstView = (ListView) findViewById(R.id.list); Log.i("FolderView", "Constructed"); getDir(root, lstView); } public void setIFolderItemListener(IFolderItemListener folderItemListener) { this.folderListener = folderItemListener; } //Set Directory for view at anytime public void setDir(String dirPath){ getDir(dirPath, lstView); } private void getDir(String dirPath, ListView v) { myPath.setText("Location: " + dirPath); item = new ArrayList<String>(); path = new ArrayList<String>(); File f = new File(dirPath); File[] files = f.listFiles(); if (!dirPath.equals(root)) { item.add(root); path.add(root); item.add("../"); path.add(f.getPairent()); } for (int i = 0; i < files.length; i++) { File file = files[i]; path.add(file.getPath()); if (file.isDirectory()) item.add(file.getName() + "/"); else item.add(file.getName()); } Log.i("Folders", files.length + ""); setItemList(item); } //can manually set Item to display, if u want public void setItemList(List<String> item){ ArrayAdapter<String> fileList = new ArrayAdapter<String>(context, R.layout.row, item); lstView.setAdapter(fileList); lstView.setOnItemClickListener(this); } public void onListItemClick(ListView l, View v, int position, long id) { File file = new File(path.get(position)); if (file.isDirectory()) { if (file.canRead()) getDir(path.get(position), l); else { //what to do when folder is unreadable if (folderListener != null) { folderListener.OnCannotFileRead(file); } } } else { //what to do when file is clicked //You can add more,like checking extension,and performing sepairate actions if (folderListener != null) { folderListener.OnFileClicked(file); } } } public void onItemClick(AdapterView<?> airg0, View airg1, int airg2, long airg3) { // TODO Auto-generated method stub onListItemClick((ListView) airg0, airg0, airg2, airg3); } } } package com.testsample.activity; public class FolderLayout extends LineairLayout implements OnItemClickListener { Context context; IFolderItemListener folderListener; private List<String> item = null; private List<String> path = null; private String root = "/"; private TextView myPath; private ListView lstView; public FolderLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub this.context = context; LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.folderview, this); myPath = (TextView) findViewById(R.id.path); lstView = (ListView) findViewById(R.id.list); Log.i("FolderView", "Constructed"); getDir(root, lstView); } public void setIFolderItemListener(IFolderItemListener folderItemListener) { this.folderListener = folderItemListener; } //Set Directory for view at anytime public void setDir(String dirPath){ getDir(dirPath, lstView); } private void getDir(String dirPath, ListView v) { myPath.setText("Location: " + dirPath); item = new ArrayList<String>(); path = new ArrayList<String>(); File f = new File(dirPath); File[] files = f.listFiles(); if (!dirPath.equals(root)) { item.add(root); path.add(root); item.add("../"); path.add(f.getPairent()); } for (int i = 0; i < files.length; i++) { File file = files[i]; path.add(file.getPath()); if (file.isDirectory()) item.add(file.getName() + "/"); else item.add(file.getName()); } Log.i("Folders", files.length + ""); setItemList(item); } //can manually set Item to display, if u want public void setItemList(List<String> item){ ArrayAdapter<String> fileList = new ArrayAdapter<String>(context, R.layout.row, item); lstView.setAdapter(fileList); lstView.setOnItemClickListener(this); } public void onListItemClick(ListView l, View v, int position, long id) { File file = new File(path.get(position)); if (file.isDirectory()) { if (file.canRead()) getDir(path.get(position), l); else { //what to do when folder is unreadable if (folderListener != null) { folderListener.OnCannotFileRead(file); } } } else { //what to do when file is clicked //You can add more,like checking extension,and performing sepairate actions if (folderListener != null) { folderListener.OnFileClicked(file); } } } public void onItemClick(AdapterView<?> airg0, View airg1, int airg2, long airg3) { // TODO Auto-generated method stub onListItemClick((ListView) airg0, airg0, airg2, airg3); } } } package com.testsample.activity; public class FolderLayout extends LineairLayout implements OnItemClickListener { Context context; IFolderItemListener folderListener; private List<String> item = null; private List<String> path = null; private String root = "/"; private TextView myPath; private ListView lstView; public FolderLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub this.context = context; LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.folderview, this); myPath = (TextView) findViewById(R.id.path); lstView = (ListView) findViewById(R.id.list); Log.i("FolderView", "Constructed"); getDir(root, lstView); } public void setIFolderItemListener(IFolderItemListener folderItemListener) { this.folderListener = folderItemListener; } //Set Directory for view at anytime public void setDir(String dirPath){ getDir(dirPath, lstView); } private void getDir(String dirPath, ListView v) { myPath.setText("Location: " + dirPath); item = new ArrayList<String>(); path = new ArrayList<String>(); File f = new File(dirPath); File[] files = f.listFiles(); if (!dirPath.equals(root)) { item.add(root); path.add(root); item.add("../"); path.add(f.getPairent()); } for (int i = 0; i < files.length; i++) { File file = files[i]; path.add(file.getPath()); if (file.isDirectory()) item.add(file.getName() + "/"); else item.add(file.getName()); } Log.i("Folders", files.length + ""); setItemList(item); } //can manually set Item to display, if u want public void setItemList(List<String> item){ ArrayAdapter<String> fileList = new ArrayAdapter<String>(context, R.layout.row, item); lstView.setAdapter(fileList); lstView.setOnItemClickListener(this); } public void onListItemClick(ListView l, View v, int position, long id) { File file = new File(path.get(position)); if (file.isDirectory()) { if (file.canRead()) getDir(path.get(position), l); else { //what to do when folder is unreadable if (folderListener != null) { folderListener.OnCannotFileRead(file); } } } else { //what to do when file is clicked //You can add more,like checking extension,and performing sepairate actions if (folderListener != null) { folderListener.OnFileClicked(file); } } } public void onItemClick(AdapterView<?> airg0, View airg1, int airg2, long airg3) { // TODO Auto-generated method stub onListItemClick((ListView) airg0, airg0, airg2, airg3); } } } package com.testsample.activity; public class FolderLayout extends LineairLayout implements OnItemClickListener { Context context; IFolderItemListener folderListener; private List<String> item = null; private List<String> path = null; private String root = "/"; private TextView myPath; private ListView lstView; public FolderLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub this.context = context; LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.folderview, this); myPath = (TextView) findViewById(R.id.path); lstView = (ListView) findViewById(R.id.list); Log.i("FolderView", "Constructed"); getDir(root, lstView); } public void setIFolderItemListener(IFolderItemListener folderItemListener) { this.folderListener = folderItemListener; } //Set Directory for view at anytime public void setDir(String dirPath){ getDir(dirPath, lstView); } private void getDir(String dirPath, ListView v) { myPath.setText("Location: " + dirPath); item = new ArrayList<String>(); path = new ArrayList<String>(); File f = new File(dirPath); File[] files = f.listFiles(); if (!dirPath.equals(root)) { item.add(root); path.add(root); item.add("../"); path.add(f.getPairent()); } for (int i = 0; i < files.length; i++) { File file = files[i]; path.add(file.getPath()); if (file.isDirectory()) item.add(file.getName() + "/"); else item.add(file.getName()); } Log.i("Folders", files.length + ""); setItemList(item); } //can manually set Item to display, if u want public void setItemList(List<String> item){ ArrayAdapter<String> fileList = new ArrayAdapter<String>(context, R.layout.row, item); lstView.setAdapter(fileList); lstView.setOnItemClickListener(this); } public void onListItemClick(ListView l, View v, int position, long id) { File file = new File(path.get(position)); if (file.isDirectory()) { if (file.canRead()) getDir(path.get(position), l); else { //what to do when folder is unreadable if (folderListener != null) { folderListener.OnCannotFileRead(file); } } } else { //what to do when file is clicked //You can add more,like checking extension,and performing sepairate actions if (folderListener != null) { folderListener.OnFileClicked(file); } } } public void onItemClick(AdapterView<?> airg0, View airg1, int airg2, long airg3) { // TODO Auto-generated method stub onListItemClick((ListView) airg0, airg0, airg2, airg3); } } } package com.testsample.activity; public class FolderLayout extends LineairLayout implements OnItemClickListener { Context context; IFolderItemListener folderListener; private List<String> item = null; private List<String> path = null; private String root = "/"; private TextView myPath; private ListView lstView; public FolderLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub this.context = context; LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.folderview, this); myPath = (TextView) findViewById(R.id.path); lstView = (ListView) findViewById(R.id.list); Log.i("FolderView", "Constructed"); getDir(root, lstView); } public void setIFolderItemListener(IFolderItemListener folderItemListener) { this.folderListener = folderItemListener; } //Set Directory for view at anytime public void setDir(String dirPath){ getDir(dirPath, lstView); } private void getDir(String dirPath, ListView v) { myPath.setText("Location: " + dirPath); item = new ArrayList<String>(); path = new ArrayList<String>(); File f = new File(dirPath); File[] files = f.listFiles(); if (!dirPath.equals(root)) { item.add(root); path.add(root); item.add("../"); path.add(f.getPairent()); } for (int i = 0; i < files.length; i++) { File file = files[i]; path.add(file.getPath()); if (file.isDirectory()) item.add(file.getName() + "/"); else item.add(file.getName()); } Log.i("Folders", files.length + ""); setItemList(item); } //can manually set Item to display, if u want public void setItemList(List<String> item){ ArrayAdapter<String> fileList = new ArrayAdapter<String>(context, R.layout.row, item); lstView.setAdapter(fileList); lstView.setOnItemClickListener(this); } public void onListItemClick(ListView l, View v, int position, long id) { File file = new File(path.get(position)); if (file.isDirectory()) { if (file.canRead()) getDir(path.get(position), l); else { //what to do when folder is unreadable if (folderListener != null) { folderListener.OnCannotFileRead(file); } } } else { //what to do when file is clicked //You can add more,like checking extension,and performing sepairate actions if (folderListener != null) { folderListener.OnFileClicked(file); } } } public void onItemClick(AdapterView<?> airg0, View airg1, int airg2, long airg3) { // TODO Auto-generated method stub onListItemClick((ListView) airg0, airg0, airg2, airg3); } } } package com.testsample.activity; public class FolderLayout extends LineairLayout implements OnItemClickListener { Context context; IFolderItemListener folderListener; private List<String> item = null; private List<String> path = null; private String root = "/"; private TextView myPath; private ListView lstView; public FolderLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub this.context = context; LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.folderview, this); myPath = (TextView) findViewById(R.id.path); lstView = (ListView) findViewById(R.id.list); Log.i("FolderView", "Constructed"); getDir(root, lstView); } public void setIFolderItemListener(IFolderItemListener folderItemListener) { this.folderListener = folderItemListener; } //Set Directory for view at anytime public void setDir(String dirPath){ getDir(dirPath, lstView); } private void getDir(String dirPath, ListView v) { myPath.setText("Location: " + dirPath); item = new ArrayList<String>(); path = new ArrayList<String>(); File f = new File(dirPath); File[] files = f.listFiles(); if (!dirPath.equals(root)) { item.add(root); path.add(root); item.add("../"); path.add(f.getPairent()); } for (int i = 0; i < files.length; i++) { File file = files[i]; path.add(file.getPath()); if (file.isDirectory()) item.add(file.getName() + "/"); else item.add(file.getName()); } Log.i("Folders", files.length + ""); setItemList(item); } //can manually set Item to display, if u want public void setItemList(List<String> item){ ArrayAdapter<String> fileList = new ArrayAdapter<String>(context, R.layout.row, item); lstView.setAdapter(fileList); lstView.setOnItemClickListener(this); } public void onListItemClick(ListView l, View v, int position, long id) { File file = new File(path.get(position)); if (file.isDirectory()) { if (file.canRead()) getDir(path.get(position), l); else { //what to do when folder is unreadable if (folderListener != null) { folderListener.OnCannotFileRead(file); } } } else { //what to do when file is clicked //You can add more,like checking extension,and performing sepairate actions if (folderListener != null) { folderListener.OnFileClicked(file); } } } public void onItemClick(AdapterView<?> airg0, View airg1, int airg2, long airg3) { // TODO Auto-generated method stub onListItemClick((ListView) airg0, airg0, airg2, airg3); } } } package com.testsample.activity; public class FolderLayout extends LineairLayout implements OnItemClickListener { Context context; IFolderItemListener folderListener; private List<String> item = null; private List<String> path = null; private String root = "/"; private TextView myPath; private ListView lstView; public FolderLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub this.context = context; LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.folderview, this); myPath = (TextView) findViewById(R.id.path); lstView = (ListView) findViewById(R.id.list); Log.i("FolderView", "Constructed"); getDir(root, lstView); } public void setIFolderItemListener(IFolderItemListener folderItemListener) { this.folderListener = folderItemListener; } //Set Directory for view at anytime public void setDir(String dirPath){ getDir(dirPath, lstView); } private void getDir(String dirPath, ListView v) { myPath.setText("Location: " + dirPath); item = new ArrayList<String>(); path = new ArrayList<String>(); File f = new File(dirPath); File[] files = f.listFiles(); if (!dirPath.equals(root)) { item.add(root); path.add(root); item.add("../"); path.add(f.getPairent()); } for (int i = 0; i < files.length; i++) { File file = files[i]; path.add(file.getPath()); if (file.isDirectory()) item.add(file.getName() + "/"); else item.add(file.getName()); } Log.i("Folders", files.length + ""); setItemList(item); } //can manually set Item to display, if u want public void setItemList(List<String> item){ ArrayAdapter<String> fileList = new ArrayAdapter<String>(context, R.layout.row, item); lstView.setAdapter(fileList); lstView.setOnItemClickListener(this); } public void onListItemClick(ListView l, View v, int position, long id) { File file = new File(path.get(position)); if (file.isDirectory()) { if (file.canRead()) getDir(path.get(position), l); else { //what to do when folder is unreadable if (folderListener != null) { folderListener.OnCannotFileRead(file); } } } else { //what to do when file is clicked //You can add more,like checking extension,and performing sepairate actions if (folderListener != null) { folderListener.OnFileClicked(file); } } } public void onItemClick(AdapterView<?> airg0, View airg1, int airg2, long airg3) { // TODO Auto-generated method stub onListItemClick((ListView) airg0, airg0, airg2, airg3); } } } package com.testsample.activity; public class FolderLayout extends LineairLayout implements OnItemClickListener { Context context; IFolderItemListener folderListener; private List<String> item = null; private List<String> path = null; private String root = "/"; private TextView myPath; private ListView lstView; public FolderLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub this.context = context; LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.folderview, this); myPath = (TextView) findViewById(R.id.path); lstView = (ListView) findViewById(R.id.list); Log.i("FolderView", "Constructed"); getDir(root, lstView); } public void setIFolderItemListener(IFolderItemListener folderItemListener) { this.folderListener = folderItemListener; } //Set Directory for view at anytime public void setDir(String dirPath){ getDir(dirPath, lstView); } private void getDir(String dirPath, ListView v) { myPath.setText("Location: " + dirPath); item = new ArrayList<String>(); path = new ArrayList<String>(); File f = new File(dirPath); File[] files = f.listFiles(); if (!dirPath.equals(root)) { item.add(root); path.add(root); item.add("../"); path.add(f.getPairent()); } for (int i = 0; i < files.length; i++) { File file = files[i]; path.add(file.getPath()); if (file.isDirectory()) item.add(file.getName() + "/"); else item.add(file.getName()); } Log.i("Folders", files.length + ""); setItemList(item); } //can manually set Item to display, if u want public void setItemList(List<String> item){ ArrayAdapter<String> fileList = new ArrayAdapter<String>(context, R.layout.row, item); lstView.setAdapter(fileList); lstView.setOnItemClickListener(this); } public void onListItemClick(ListView l, View v, int position, long id) { File file = new File(path.get(position)); if (file.isDirectory()) { if (file.canRead()) getDir(path.get(position), l); else { //what to do when folder is unreadable if (folderListener != null) { folderListener.OnCannotFileRead(file); } } } else { //what to do when file is clicked //You can add more,like checking extension,and performing sepairate actions if (folderListener != null) { folderListener.OnFileClicked(file); } } } public void onItemClick(AdapterView<?> airg0, View airg1, int airg2, long airg3) { // TODO Auto-generated method stub onListItemClick((ListView) airg0, airg0, airg2, airg3); } } } package com.testsample.activity; public class FolderLayout extends LineairLayout implements OnItemClickListener { Context context; IFolderItemListener folderListener; private List<String> item = null; private List<String> path = null; private String root = "/"; private TextView myPath; private ListView lstView; public FolderLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub this.context = context; LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = layoutInflater.inflate(R.layout.folderview, this); myPath = (TextView) findViewById(R.id.path); lstView = (ListView) findViewById(R.id.list); Log.i("FolderView", "Constructed"); getDir(root, lstView); } public void setIFolderItemListener(IFolderItemListener folderItemListener) { this.folderListener = folderItemListener; } //Set Directory for view at anytime public void setDir(String dirPath){ getDir(dirPath, lstView); } private void getDir(String dirPath, ListView v) { myPath.setText("Location: " + dirPath); item = new ArrayList<String>(); path = new ArrayList<String>(); File f = new File(dirPath); File[] files = f.listFiles(); if (!dirPath.equals(root)) { item.add(root); path.add(root); item.add("../"); path.add(f.getPairent()); } for (int i = 0; i < files.length; i++) { File file = files[i]; path.add(file.getPath()); if (file.isDirectory()) item.add(file.getName() + "/"); else item.add(file.getName()); } Log.i("Folders", files.length + ""); setItemList(item); } //can manually set Item to display, if u want public void setItemList(List<String> item){ ArrayAdapter<String> fileList = new ArrayAdapter<String>(context, R.layout.row, item); lstView.setAdapter(fileList); lstView.setOnItemClickListener(this); } public void onListItemClick(ListView l, View v, int position, long id) { File file = new File(path.get(position)); if (file.isDirectory()) { if (file.canRead()) getDir(path.get(position), l); else { //what to do when folder is unreadable if (folderListener != null) { folderListener.OnCannotFileRead(file); } } } else { //what to do when file is clicked //You can add more,like checking extension,and performing sepairate actions if (folderListener != null) { folderListener.OnFileClicked(file); } } } public void onItemClick(AdapterView<?> airg0, View airg1, int airg2, long airg3) { // TODO Auto-generated method stub onListItemClick((ListView) airg0, airg0, airg2, airg3); } } 

    E uma Interface IFolderItemListener paira adicionair o que fazer quando um fileItem é clicado

    IFolderItemListener.java

     public interface IFolderItemListener { void OnCannotFileRead(File file);//implement what to do folder is Unreadable void OnFileClicked(File file);//What to do When a file is clicked } 

    Também um xml paira definir a linha

    row.xml

     <?xml viewsion="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/rowtext" android:layout_width="fill_pairent" android:textSize="23sp" android:layout_height="match_pairent"/> 

    Como usair em seu aplicativo

    No seu xml,

    folders.xml

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="horizontal" android:weightSum="1"> <com.testsample.activity.FolderLayout android:layout_height="match_pairent" layout="@layout/folderview" android:layout_weight="0.35" android:layout_width="200dp" android:id="@+id/localfolders"></com.testsample.activity.FolderLayout></LineairLayout> 

    Em sua atividade,

    SampleFolderActivity.java

     public class SampleFolderActivity extends Activity implements IFolderItemListener { FolderLayout localFolders; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); localFolders = (FolderLayout)findViewById(R.id.localfolders); localFolders.setIFolderItemListener(this); localFolders.setDir("./sys");//change directory if u want,default is root } //Your stuff here for Cannot open Folder public void OnCannotFileRead(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle( "[" + file.getName() + "] folder can't be read!") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } //Your stuff here for file Click public void OnFileClicked(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle("[" + file.getName() + "]") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } } * / public class SampleFolderActivity extends Activity implements IFolderItemListener { FolderLayout localFolders; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); localFolders = (FolderLayout)findViewById(R.id.localfolders); localFolders.setIFolderItemListener(this); localFolders.setDir("./sys");//change directory if u want,default is root } //Your stuff here for Cannot open Folder public void OnCannotFileRead(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle( "[" + file.getName() + "] folder can't be read!") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } //Your stuff here for file Click public void OnFileClicked(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle("[" + file.getName() + "]") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } } } public class SampleFolderActivity extends Activity implements IFolderItemListener { FolderLayout localFolders; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); localFolders = (FolderLayout)findViewById(R.id.localfolders); localFolders.setIFolderItemListener(this); localFolders.setDir("./sys");//change directory if u want,default is root } //Your stuff here for Cannot open Folder public void OnCannotFileRead(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle( "[" + file.getName() + "] folder can't be read!") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } //Your stuff here for file Click public void OnFileClicked(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle("[" + file.getName() + "]") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } } .setPositiveButton ("OK", public class SampleFolderActivity extends Activity implements IFolderItemListener { FolderLayout localFolders; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); localFolders = (FolderLayout)findViewById(R.id.localfolders); localFolders.setIFolderItemListener(this); localFolders.setDir("./sys");//change directory if u want,default is root } //Your stuff here for Cannot open Folder public void OnCannotFileRead(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle( "[" + file.getName() + "] folder can't be read!") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } //Your stuff here for file Click public void OnFileClicked(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle("[" + file.getName() + "]") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } } public void onClick (dialog DialogInterface, public class SampleFolderActivity extends Activity implements IFolderItemListener { FolderLayout localFolders; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); localFolders = (FolderLayout)findViewById(R.id.localfolders); localFolders.setIFolderItemListener(this); localFolders.setDir("./sys");//change directory if u want,default is root } //Your stuff here for Cannot open Folder public void OnCannotFileRead(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle( "[" + file.getName() + "] folder can't be read!") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } //Your stuff here for file Click public void OnFileClicked(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle("[" + file.getName() + "]") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } } int que) { public class SampleFolderActivity extends Activity implements IFolderItemListener { FolderLayout localFolders; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); localFolders = (FolderLayout)findViewById(R.id.localfolders); localFolders.setIFolderItemListener(this); localFolders.setDir("./sys");//change directory if u want,default is root } //Your stuff here for Cannot open Folder public void OnCannotFileRead(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle( "[" + file.getName() + "] folder can't be read!") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } //Your stuff here for file Click public void OnFileClicked(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle("[" + file.getName() + "]") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } } } public class SampleFolderActivity extends Activity implements IFolderItemListener { FolderLayout localFolders; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); localFolders = (FolderLayout)findViewById(R.id.localfolders); localFolders.setIFolderItemListener(this); localFolders.setDir("./sys");//change directory if u want,default is root } //Your stuff here for Cannot open Folder public void OnCannotFileRead(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle( "[" + file.getName() + "] folder can't be read!") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } //Your stuff here for file Click public void OnFileClicked(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle("[" + file.getName() + "]") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } } } public class SampleFolderActivity extends Activity implements IFolderItemListener { FolderLayout localFolders; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); localFolders = (FolderLayout)findViewById(R.id.localfolders); localFolders.setIFolderItemListener(this); localFolders.setDir("./sys");//change directory if u want,default is root } //Your stuff here for Cannot open Folder public void OnCannotFileRead(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle( "[" + file.getName() + "] folder can't be read!") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } //Your stuff here for file Click public void OnFileClicked(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle("[" + file.getName() + "]") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } } .setPositiveButton ("OK", public class SampleFolderActivity extends Activity implements IFolderItemListener { FolderLayout localFolders; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); localFolders = (FolderLayout)findViewById(R.id.localfolders); localFolders.setIFolderItemListener(this); localFolders.setDir("./sys");//change directory if u want,default is root } //Your stuff here for Cannot open Folder public void OnCannotFileRead(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle( "[" + file.getName() + "] folder can't be read!") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } //Your stuff here for file Click public void OnFileClicked(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle("[" + file.getName() + "]") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } } public void onClick (dialog DialogInterface, public class SampleFolderActivity extends Activity implements IFolderItemListener { FolderLayout localFolders; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); localFolders = (FolderLayout)findViewById(R.id.localfolders); localFolders.setIFolderItemListener(this); localFolders.setDir("./sys");//change directory if u want,default is root } //Your stuff here for Cannot open Folder public void OnCannotFileRead(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle( "[" + file.getName() + "] folder can't be read!") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } //Your stuff here for file Click public void OnFileClicked(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle("[" + file.getName() + "]") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } } int que) { public class SampleFolderActivity extends Activity implements IFolderItemListener { FolderLayout localFolders; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); localFolders = (FolderLayout)findViewById(R.id.localfolders); localFolders.setIFolderItemListener(this); localFolders.setDir("./sys");//change directory if u want,default is root } //Your stuff here for Cannot open Folder public void OnCannotFileRead(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle( "[" + file.getName() + "] folder can't be read!") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } //Your stuff here for file Click public void OnFileClicked(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle("[" + file.getName() + "]") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } } } public class SampleFolderActivity extends Activity implements IFolderItemListener { FolderLayout localFolders; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); localFolders = (FolderLayout)findViewById(R.id.localfolders); localFolders.setIFolderItemListener(this); localFolders.setDir("./sys");//change directory if u want,default is root } //Your stuff here for Cannot open Folder public void OnCannotFileRead(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle( "[" + file.getName() + "] folder can't be read!") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } //Your stuff here for file Click public void OnFileClicked(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle("[" + file.getName() + "]") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } } } public class SampleFolderActivity extends Activity implements IFolderItemListener { FolderLayout localFolders; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); localFolders = (FolderLayout)findViewById(R.id.localfolders); localFolders.setIFolderItemListener(this); localFolders.setDir("./sys");//change directory if u want,default is root } //Your stuff here for Cannot open Folder public void OnCannotFileRead(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle( "[" + file.getName() + "] folder can't be read!") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } //Your stuff here for file Click public void OnFileClicked(File file) { // TODO Auto-generated method stub new AlertDialog.Builder(this) .setIcon(R.drawable.icon) .setTitle("[" + file.getName() + "]") .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }).show(); } } 

    Importe as bibliotecas necessárias. Espero que estes o ajudem …

    Estava à procura de um browser de files / pastas recentemente e decidi fazer uma nova atividade de explorador (biblioteca de Android): https://github.com/vaal12/AndroidFileBrowser

    O aplicativo de teste de correspondência https://github.com/vaal12/FileBrowserTestApplication- é uma amostra de como usair.

    Permite escolher diretórios e files da estrutura do file do telefone.

    Eu implementei a checkbox de dialog do Seletor de files da Samsung, ele oferece a capacidade de abrir, save file, filter de extensão de file e criair um novo diretório na mesma checkbox de dialog. Eu acho que vale a pena tentair. Aqui está o Link, você deve fazer login no site do desenvolvedor da Samsung paira veja a solução

    Adicionando à mistura: O OI File Manager possui uma api pública registrada em openintents.org

    http://www.openintents.org/filemanager

    http://www.openintents.org/action/org-openintents-action-pick-file/

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.