B4A Library FilePicker

This is a wrap for this github project.

The lib requires B4A 6+

This is my 100. Library-Release for B4A :)

FilePicker
Author:
DonManfred (wrapper)
Version: 1.01
  • DialogProperties
    Methods:
    • Initialize (EventName As String, root As String, selectionMode As Int, selectionType As Int, extensions() As String)
      Selection Mode defines whether a single of
      multiple Files/Directories have to be selected.
      SINGLE_MODE and MULTI_MODE are the two selection modes,
      See DialogConfigs for more info.
      Set to Single Mode by default.

      Selection Type defines that whether a File/Directory or both of these has
      has to be selected.

      FILE_SELECT ,DIR_SELECT, FILE_AND_DIR_SELECT are the three selection modes,
      See DialogConfigs for more info. Set to FILE_SELECT by default.

      root = The Parent/Root Directory. List of Files are populated from here.
      Can be set to any readable directory. /sdcard is the default location.

      extensions = An Array of String containing extensions, Files with only that will be shown.
      Others will be ignored. Set to null by default.
      Eg. String ext={"jpg","jpeg","png","gif"};
    • IsInitialized As Boolean
  • FileListItem
    Methods:
    • Initialize (EventName As String)
    • IsInitialized As Boolean
    • compareTo (fileListItem As FileListItem) As Int
    • isDirectory As Boolean
    • isMarked As Boolean
    Properties:
    • Directory As Boolean [write only]
    • Filename As String
    • Location As String
    • Marked As Boolean [write only]
    • Time As Long
  • FilePickerDialog
    Events:
    • _onSelectedFilePaths (selected[] As String)
    Methods:
    • Initialize (EventName As String)
    • IsInitialized As Boolean
    • cancel
    • closeOptionsMenu
    • dismiss
    • openContextMenu (view As View)
    • openOptionsMenu
    • show
    Properties:
    • Properties As DialogProperties
 

Attachments

  • FilePickerEx.zip
    6.8 KB · Views: 1,458
  • FilePickerV1.01.zip
    28.5 KB · Views: 1,501
Last edited:

DonManfred

Expert
Licensed User
Longtime User
check the parameters in initialize... you can set only folders, only files, both....
 

so27

Active Member
Licensed User
Longtime User
I could not see the fields. White on white. I set in the manifest file some material colors and already I see the check boxes. Thanks.
 

ivan.tellez

Active Member
Licensed User
Longtime User
This could be useful:

B4X:
 '  SELECTION_MODES

  '  SINGLE_MODE specifies that a single File/Directory has to be selected
  '  from the list of Files/Directories. It is the default Selection Mode.
   
  Dim Const SINGLE_MODE As Int = 0;

  '  MULTI_MODE specifies that multiple Files/Directories has to be selected
  '  from the list of Files/Directories.
   
  Dim Const MULTI_MODE As Int = 1;

  '  SELECTION_TYPES

  '  FILE_SELECT specifies that from list of Files/Directories a File has to
  '  be selected.
   
  Dim Const FILE_SELECT As Int = 0;

  '  DIR_SELECT specifies that from list of Files/Directories a Directory has to
  '  be selected. It is the default Selection Type.
   
  Dim Const DIR_SELECT As Int = 1;

  '  FILE_AND_DIR_SELECT specifies that from list of Files/Directories both
  '  can be selected.
 
  Dim Const FILE_AND_DIR_SELECT As Int = 2;
 

JoanRPM

Active Member
Licensed User
Longtime User
Hello.

I'm trying to use this library, bu I have a compiler error:

B4A version: 6.00
Parsing code. (0.02s)
Compiling code. (0.16s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
Generating R file. Error
C:\Projectes\Prog\Proves\Android\FilePicker\FilePicker\Objects\bin\extra\res1\res\layout\dialog_file_list_item.xml:12: error: No resource identifier found for attribute 'layout_marginStart' in package 'android'
C:\Projectes\Prog\Proves\Android\FilePicker\FilePicker\Objects\bin\extra\res1\res\layout\dialog_file_list_item.xml:21: error: No resource identifier found for attribute 'layout_marginStart' in package 'android'
C:\Projectes\Prog\Proves\Android\FilePicker\FilePicker\Objects\bin\extra\res1\res\layout\dialog_header.xml:9: error: No resource identifier found for attribute 'layout_marginStart' in package 'android'
C:\Projectes\Prog\Proves\Android\FilePicker\FilePicker\Objects\bin\extra\res1\res\layout\dialog_header.xml:23: error: No resource identifier found for attribute 'layout_marginStart' in package 'android'
C:\Projectes\Prog\Proves\Android\FilePicker\FilePicker\Objects\bin\extra\res1\res\layout\dialog_header.xml:33: error: No resource identifier found for attribute 'layout_marginStart' in package 'android'

I put the 3 files "FilePickerV1.01.zip" in the Library folder.

What can I do?

Thanks.
 

JoanRPM

Active Member
Licensed User
Longtime User
DonManfred.

It's your example.
Android Version is 4.4.2.

The problem is the jar API. I change to API 19 and it works.

Thanks.
 
Last edited:

cb56

Member
Licensed User
Longtime User
Great work!
Only one thing ...could you disable the "Select" button if nothing is selected?

Thanks

Edit: Another tip: can you increase the size of the check? Often it happens to enter the folder instead of select it.
Even touching the check right should not enter the folder.

It would be a useful option to change the color of the folder, the background and text.

Thanks
 
Last edited:

MitchBu

Well-Known Member
Licensed User
Longtime User
Hi DonManfred,

I would like to use your superb FilePicker to select pictures to load into an ImageView, but I am stuck figuring out path and filename to do this kind of thing fictitious path and filename) :
B4X:
ImageView1.Bitmap = LoadBitmap(File.DirRootExternal, "myPic.png")
 

MitchBu

Well-Known Member
Licensed User
Longtime User
Hi DonManfred,

I would like to use your superb FilePicker to select pictures to load into an ImageView, but I am stuck figuring out path and filename to do this kind of thing fictitious path and filename) :
B4X:
ImageView1.Bitmap = LoadBitmap(File.DirRootExternal, "myPic.png")

I will reply to my own question in case someone else had the same question.

It works by putting the complete path as first argument, and nothing in filename :
B4X:
ImageView1.Bitmap = LoadBitmap(selected(0), "")
 

Robert Valentino

Well-Known Member
Licensed User
Longtime User
it possible to use this library with B4J

I am trying but keep getting Cannot find: C:\Program Files (x86)\Anywhere Software\B4J\libraries\filepicker-1.0.1.aar.jar

I have the file in my B4J additional libraries
 
Top