Android File Dialog Tutorial using Basic4Android
Submitted by donbermoy on Tuesday, January 21, 2014 - 14:45.
This is my continuation in our Dialog example and next to be discussed is the File Dialog.
First, we have to create our Layout name and named it as "Main" and have one button named Button1. You need to initialized the following variables in the Sub Globals below:
Take note that bmp here is used as our variable to create an icon for our file dialog.
Here is our complete code for this tutorial:
Note:
fd - used as our variable for FileDialog
ret - used as our variable for Object.
fd.FastScroll - a boolean syntax if you want to have the speed of the scrollbar to make fast.
fd.KeyboardPopUp - syntax for pop-upping the keyboard.
fd.FileFilter - syntax for filtering the type of file to be searched.
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
- Sub Globals
- 'These global variables will be redeclared each time the activity is created.
- 'These variables can only be accessed from this module.
- Dim Button1 As Button
- Dim bmp As Bitmap
- End Sub
- Sub Process_Globals
- 'These global variables will be declared once when the application starts.
- 'These variables can be accessed from all modules.
- End Sub
- Sub Activity_Create(FirstTime As Boolean)
- 'Do not forget to load the layout file created with the visual designer. For example:
- 'Activity.LoadLayout("Layout1")
- Activity.LoadLayout("Main")
- bmp.InitializeSample(File.DirAssets, "bermoy.jpg",48,48)
- Activity.Title = "File Dialog - Lyndon Bermoy"
- End Sub
- Sub Activity_Resume
- End Sub
- Sub Activity_Pause (UserClosedAs Boolean)
- End Sub
- Sub Button1_Click
- Dim fd As FileDialog
- Dim ret As Object
- fd.FastScroll = True
- fd.KeyboardPopUp = False
- 'fd.ShowOnlyFolders = True
- fd.FilePath = File.DirRootExternal ' also sets ChosenName to an emtpy string
- 'fd.ShowOnlyFolders = true
- 'fd.FileFilter = ".txt" ' for example or ".jpg,.png" for multiple file types
- ret = fd.Show("B4A File Dialog", "Yes", "No", "Maybe", bmp)
- ToastMessageShow(ret & " : Path : " &fd.FilePath& CRLF & "File : " &fd.ChosenName, False)
- End Sub
Add new comment
- 417 views