-
Notifications
You must be signed in to change notification settings - Fork 1
Home
FileDialog is a select file / directory dialog box for Android. She's very simple to integrate it to your project and really easy to use and configure.
FileDialog est une boite de dialogue pour sélectionner les fichiers / répertoires pour Android. Elle est très simple à intégrer à votre projet et vraiment facile à utiliser et configurer.
Go to Source section and open file src/FileDialog.java Direct link
2 methods to integrate it in your project :
- Download the file and add it in your project.
- Create a class in your project called
FileDialog.java
. Copy / Paste the entire code.
Allez dans la section Source et ouvrez le fichier src/FileDialog.java Lien direct
2 méthodes pour l'intégrer à votre projet :
- Téléchargez le fichier et ajoutez le à votre projet.
- Créez un fichier dans votre projet nommé
FileDialog.java
. Copier / Coller le code en entier.
An example is better than a long speech...
Un exemple vaut mieux qu'un long discours...
// Instantiate the class
FileDialog fd = new FileDialog(this);
// Add a listener for capture user action
fd.setListener(new FileDialog.ActionListener(){
public void userAction(int action, String path)
{
// Test if user select a directory
if (action == FileDialog.ACTION_SELECTED_DIRECTORY)
doSomething(path);
}});
// Show the dialog box
fd.selectDirectory();
// Instancie la classe
FileDialog fd = new FileDialog(this);
// Ajoute un listener pour capturer l'action d'un utilisateur
fd.setListener(new FileDialog.ActionListener(){
public void userAction(int action, String path)
{
// Test si l'utilisateur a sélectionné un répertoire
if (action == FileDialog.ACTION_SELECTED_DIRECTORY)
doSomething(path);
}});
// Afficher la boite de dialogue
fd.selectDirectory();
// Instantiate the class
FileDialog fd = new FileDialog(this);
// Add a listener for capture user action
fd.setListener(new FileDialog.ActionListener(){
public void userAction(int action, String filePath)
{
// Test if user select a file
if (action == FileDialog.ACTION_SELECTED_FILE)
doSomething(filePath);
}});
// Show the dialog box
fd.selectFile();
With selectFile
method, user can create new file and new directories. For strict select file, use selectFileStrict
// Instancie la classe
FileDialog fd = new FileDialog(this);
// Ajoute un listener pour capturer l'action d'un utilisateur
fd.setListener(new FileDialog.ActionListener(){
public void userAction(int action, String filePath)
{
// Test si l'utilisateur a sélectionné un fichier
if (action == FileDialog.ACTION_SELECTED_FILE)
doSomething(filePath);
}});
// Afficher la boite de dialogue
fd.selectFile();
Avec la méthode selectFile
, l'utilisateur peut créer un nouveau fichier et des nouveaux répertoire. Pour une sélection de fichier stricte, utilisez selectFileStrict
When user select a file, he can create a new file an you can suggest a name :
fd.setSuggestedFileName("file.sav");
Quand un utilisateur sélectionne un fichier, il peut créer un nouveau fichier et vous pouvez lui suggérer un nom :
fd.setSuggestedFileName("fichier.sav");
Default path is /sdcard/, you can change it :
fd.setPath("/sdcard/save");
Le répertoire par défaut est /sdcard/, vous pouvez le changer :
fd.setPath("/sdcard/sauvegarde");
When user do an action, dialog box call the listener and return an action :
Action | Data |
---|---|
FileDialog.ACTION_SELECTED_FILE | Path of the file |
ACTION_SELECTED_DIRECTORY | Path of the directory |
ACTION_CANCEL | null |
Quand un utilisateur fait une action, la boite de dialogue appelle le listener et renvoie une action :
Action | Data |
---|---|
FileDialog.ACTION_SELECTED_FILE | Chemin du fichier |
ACTION_SELECTED_DIRECTORY | Chemin du répertoire |
ACTION_CANCEL | null |