※上記の広告は60日以上更新のないWIKIに表示されています。更新することで広告が下部へ移動します。


What's this?


As far as I know, Android SDK has no offering of standard FileDialog as it exists for Java SE. I thought it might help to make something simple available. It's just a toy code. Feel free to do anything with it.



What it does


It works in four modes
1. Select file
2. Create file
3. Select directory
4. Create directory

In mode 1 and 3, the file dialog have the user select existing file / directory. User can navigate through the file system up and down and tap on the desired the file (Figure 1). In case of selecting directory, user can press <Here> to specify the current directory.

In mode 2 and 4, the file dialog have the user enter the new file / directory name that he wishes to create. User can navigate through the file system up and down and tap <Here> to designate where the file should be created (Figure 2). Then a text box dialog appears and asks for the new file / directory name (Figure 3). In case a file is selected, the text box is brought up with the selected file name filled in.

How it works


Here's an example code you'll find in the download package.

The code inside onCreate() corresponds to the four mode explained above. The first argument is the initial directory. The second and third controls the mode. And the fourth and fifth passes the Context and FileDialogue.Listener. FileDialogue.Listener must be implemented to receive the result from FileDialogue.

fd.showDialogue() launches the dialog box. When user has made selection, onSelected() is invoked with the directory and file name as an argument (filename will be "" when ). Else when user has pressed the "back" button, onCanceled() is invoked.

That's it!

public class FdExample extends Activity implements FileDialogue.Listener {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		// (1) Select file, starting direcotry is /sdcard/
		FileDialogue fd = new FileDialogue(null, FileDialogue.FILE, FileDialogue.SELECT, this, this);

		// (2) Create file, starting direcotry is /sdcard/, user will be requested to enter filename
		// FileDialogue fd = new FileDialogue("/sdcard/picture/", FileDialogue.FILE, FileDialogue.CREATE, this, this);

		// (3) Select directory, starting direcotry is /sdcard
		// FileDialogue fd = new FileDialogue(null, FileDialogue.DIRECTORY, FileDialogue.SELECT, this, this);

		// (4) Create directory, starting direcotry is /sdcard/, user will be requested to enter direcotry name
		// FileDialogue fd = new FileDialogue(null, FileDialogue.DIRECTORY, FileDialogue.CREATE, this, this);

		fd.showDialogue();
	}

	public void onSelected(String directory, String filename) {
		// filename will be "" when target is the FileDialogue.DIRECOTRY
		Log.v("FdExample", "Directory = " + directory + ", File = " + filename);
	}

	public void onCanceled() {
		// this is when "back" button is pressed
		Log.v("FdExample", "Canceled");
	}
}

Is this as good as it gets?


Actually, I had never liked the file dialog in general. It is rather tiring to use it. As it is launched, I must resolve where I am now and plan how I should travel to the objective location. It's a lot of screen interpretation, a lot of structural memory challenge, and not even a hint of joy. It it one UI scheme that abuses the weak parts of the human capability.

So we have some idea going. We are thinking we can create a better alternative that can take advantage of parallel processing of visual image and geometric / chromatic memory -- human is much better at those. It will be quick to get desired location, much less stressful to use, and hopefully fun. I hope we can implement the idea quickly and make available through this wiki soon.


  • アルバイトはじめましたd(´∀`*)グッ♪ http://www.e29.mobi/ -- (わかりません) 2012-01-05 04:12:48
名前:
コメント:

すべてのコメントを見る