Esparver
Esparver

Reputation: 1555

Change layout dynamically in DialogFragment

I want to use a Dialog to allow the user to scan its device for all the files with a certain extension and import some of them.

To do that, I plan to show a dialog, which will have the following behaviour:

  1. While I scan the SD card, the dialog will show a progress bar and one TextView with the path of the last file found.
  2. After scanning all the SD card, I will show a list in the same dialog with all the files found. The user will select some of them (with checkboxes) and click on "Import" or "Cancel".

I'm wondering what's the best strategy to implement this?

I can think of two possibilites:

Upvotes: 0

Views: 1292

Answers (1)

Kitesurfer
Kitesurfer

Reputation: 3561

Display a ListView into your DialogFragment and use an emptyView for the progress. Implement a Loader to scan for your Files. When the loader finished the work simply use an Adapter for your ListView and the Empty View will disappear automatically.

Upvotes: 2

Related Questions