• Register now to get access to thousands of Tutorials, Leaked content, Hot NSFW and much more. Join us as we build and grow the community.

Advertise Here

Advertise Here

Advertise Here

Android File Dialog Tutorial using Basic4Android

red1353

System Dependency Auditor
R Rep
0
0
0
Rep
0
R Vouches
0
0
0
Vouches
0
Posts
41
Likes
152
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 2 1000 XP
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:

  1. Sub

    Globals
  2. 'These global variables will be redeclared each time the activity is created.
  3. 'These variables can only be accessed from this module.

  4. Dim

    Button1 As

    Button
  5. Dim

    bmp As

    Bitmap
  6. End

    Sub

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:
  1. Sub

    Process_Globals
  2. 'These global variables will be declared once when the application starts.
  3. 'These variables can be accessed from all modules.

  4. End

    Sub
  5. Sub

    Activity_Create(FirstTime As

    Boolean

    )
  6. 'Do not forget to load the layout file created with the visual designer. For example:
  7. 'Activity.LoadLayout("Layout1")
  8. Activity.LoadLayout("Main"

    )
  9. bmp.InitializeSample(File.DirAssets, "bermoy.jpg"

    ,48,48)
  10. Activity.Title = "File Dialog - Lyndon Bermoy"

  11. End

    Sub

  12. Sub

    Activity_Resume

  13. End

    Sub

  14. Sub

    Activity_Pause (UserClosedAs Boolean

    )

  15. End

    Sub

  16. Sub

    Button1_Click
  17. Dim

    fd As

    FileDialog
  18. Dim

    ret As

    Object
  19. fd.FastScroll = True
  20. fd.KeyboardPopUp = False
  21. 'fd.ShowOnlyFolders = True
  22. fd.FilePath = File.DirRootExternal ' also sets ChosenName to an emtpy string
  23. 'fd.ShowOnlyFolders = true
  24. 'fd.FileFilter = ".txt" ' for example or ".jpg,.png" for multiple file types
  25. ret = fd.Show("B4A File Dialog"

    , "Yes"

    , "No"

    , "Maybe"

    , bmp)
  26. ToastMessageShow(ret & " : Path : "

    &fd.FilePath& CRLF & "File : "

    &fd.ChosenName, False

    )
  27. End

    Sub

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


Download
You must upgrade your account or reply in the thread to view the hidden content.
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

452,500

350,639

350,649

Top