This question already has an answer here:
How can I display a Progress at start up application in android
(1 answer)
Closed 5 years ago.
I have a heavy user interface that can delay the application load. I want to show an preloader before the UI of activity loaded. note that my ui is in xml file
EDIT:
If you want to load 10 tabs in a view pager, use a FragmentStatePagerAdapter which only loads neighboring tabs(default behavior).
If the heavy UI you specify is only the UI elements, then the app must freeze while loading it. So you'd better show a non-cancelable dialog(without animation) with loading message and after a few moment (like 200ms) load up your UI and explicitly dismiss the dialog.
But if the heavy stuffs is not just UI, maybe some calculations or image processing, just do it in a background thread while showing a dialog with progress and cancel the dialog when the task is done.
#Hassan according to me if on clicking the launcher icon if it takes sometime for your application to render the first screen(perhaps giving a black screen in between). This needs to be corrected in your application.
On the contrary if your applications main screen requires population/retrieval of certain resources for effectively engaging the users, You can possibly do something like a splash screen(outdated) where you do all "population/retrieval" and then simply pass data to your heavy UI.
Now regarding the progress bar if this fetching of data is small, you can give an indeterminate "custom"(some moving animation that would suite your app) progress bar,else if its something like a download you can easily track its progress and show in a horizontal progressbar
You sure can! You are describing a preloader. Here is a nice example of one https://github.com/rtheunissen/md-preloader
You'll have to add more info to your question to get a specific answer, but there are a few basic principles.
You make your life a lot easier if you use a preloader which doesn't show progress of the load, it just goes round and round, because the speed of some load processes can't be measured.
If its a data-load which is taking the time (such as a call to an API), you might want to set a variable for "loading" to true at the top of your script, then when the data has resolved, set it to "false". In your view, have a state or a conditional element which hides / unhides the preloader.
If lots of images are slowing down the page, you might want to look into "lazy-loading" or using "infinite scroll" to only show content when the UI needs to display it on screen.
Thats all the info I can give without more information on the code you have so far. Hope that helps!
Related
I have an App with retrofit and I make some calls to an Api (like a LogIn in this case), some of them take a few seconds to load, so I want to know when I should make a loading screen and lock the interaction with the user. I see that ProgressDialog is deprecated now, and they don't display it but they lock the interaction with the view. What should be better?
First of all it is not ProgressBar but it is ProgressDialog because it locks down user interaction until it hides.
You can use a progress indicator like ProgressBar, which can be embedded in your app's UI. Alternatively, you can use a notification to inform the user of the task's progress.Here
A skeleton screen helps load a user interface gradually, a little at a time. This means that the barebones UI displays first. Then the loaded content is gradually populated on-screen.
Shimmer effect was created by Facebook to indicate a loading status, so instead of using ProgressBar or usual loader use Shimmer for a better design and user interface.
I have a vocab building app with different vocab categories displayed in a list view. I want to have a circular progress indicator for each category that shows how familiar the user is with the vocab stored in it. I know that Android has a built-in Progress Bar. The design is what I'm looking for, however, it appears that the progress bar is running continuously by default. Whereas in my case, I just want it to be static and updated only when the activity that displayed the category items are (re)opened. So to summarize again, the main difference is that the progress bar I'm looking for isn't dependent on a process that is currently running but instead from an SQLite database where I stored information on how familiar the user is with each vocab.
I have searched online and I wasn't able to solve this problem since progress bar is usually implied to be dependent on a running process.
Thank you so much for any help in advance!
The Android ProgressBar is designed to show the progress of a process, yes, you are correct. They can be either determinate (they go from beginning to end... like a BAR), or indeterminate (they go round and round... like a CIRCLE). Circular progressbars are indeterminate and therefore do not communicate progress per-se, only that there is something in the process of "progressing" and not finished yet.
You say you want to use this widget to communicate to the user what their PERSONAL progress is in a given area.
If you insist on using the ProgressBar widget, then you would need to use a determinate one (horizontal)...
But you do not need the progress bar widget... just make your own indicator or some kind... like
1) Using views/animations, like create a view space and tell it to fill 60%, 20%, whatever...
2) make your own set of bitmap files (say, 5 of them representing 0%, 25%, 50%, 75%, 100% on a circular progress bar)... and swap them out depending on the users progress.
I have an app where an action by the user sometimes causes the app to get data from the server before it can be displayed, like getting detail info for an item (the info is too large to preload it for all items) or refreshing all data.
While this is in process i don't want the user to do anything else. What is the guideline to display a "please wait" message? Ideally it should be possible for the user to cancel the request if he wants to.
I can do it with an alert dialog, but the operation usually takes just half a second to a second, and imo it looks really strange for an alert dialog to pop up just for a moment, maybe not even long enough to be able to read the message.
Another option i see is the snack bar, but it doesn't prevent the user from doing anything else or navigate away.
Is there a guideline or best practice what to do in this scenario?
I'm using Xamarin.Android, but i don't think that matters.
You can show a loading circle in place where the content being loaded will be displayed like this. When it finishes, replace the loading circle with the content.
Actually "i don't want the user to do anything else" is not acceptable in most Android design patterns. Android app should allow the user to take control of the app.
About canceling the request, you can add a cancel button near the loading circle, or add a cross inside the circle which will stop the process when being pressed. The latter is preferred.
For more patterns see this.
About progress dialog
As far as I know, progress dialog which block the user interaction is discouraged in the new Android. But I am sorry that I cannot find the reference yet, maybe somewhere in Material Design guidelines document. However, because you are the developer, it's all up to you :D.
Check out the documentation on AsyncTask.
I would do the long running task in an AsyncTask, show a ProgressDialog in it's onPreExecute method and hide it after it finised, in onPostExecute.
To prevent the user from closing the dialog you can use the Dialog.setCancelable() method.
You can define a custom layout for your Dialog and set it via the setContentView() method.
I'm new in the forum and new in android development.
I searched all over internet and around stackoverflow but I can't get an practical answer to my issues. I want to know your opinions about the best approach (handlers, async tasks, etc....) to my application. I have:
**1 - A button that when is clicked must show a list (the data is obtained parsin an html response)
2 - While the list isn't loaded the application must show a "Loading" dialog.**
Now I can load de list when I click on the button, but sometimes (depending on the internet connecxtion) it can take to long and I want to show the Loading progress dialog.
I tried to implement AsyncTasks but win the method onPostExecute the dialog was closed but the list wasn't shown on the UI despite it was with correct data.
Can anyone help me with the best approach?
Thank you very much.
You have two obvious solutions here you can choose from:
1) Put a ProgressBar within your Layout XML and have it set to View.GONE until the button is pressed and then change to View.VISIBLE, changing to View.GONE again on finish.
2) Have a separate Layout XML with a more details loading view and use setContentView to switch between the both during requests.
I often go with the View.GONE ProgressBar approach
I'd like to have a splash screen while loading resources (images and sounds). How do I know everything is loaded?
Are all resources loaded at app startup?
Thanks
For accordingly implementing a splash screen in Android you want to:
Show a foreground screen with some progress indication for the user.
Execute a background thread for doing tasks that take some indefinitive time.
Both threads communicating between them, as you need the foreground to show the progress on the background.
Correctly kill the background thread when it finishes doing it's task. If you are planning to use AsyncTask in Android you have an issue there. (Link)
I've found this tutorial and I strongly suggest it:http://www.41post.com/4588/programming/android-coding-a-loading-screen-part-1
Part 1 accomplish this basic task, part 2 shows you how to correctly kill the AsyncTask. And part 3 puts a customized view in the foreground instead of the ProgressActivity.
You could do all your loading in an asyncTask then your onPostExecute remove the splash screen. This would help ensure that you don't block the UI thread while doing any expensive tasks that could cause an ANR popup.
Here you go, wrote a tutorial on how to create a SplashScreen with a progress bar:
http://blog.blundellapps.com/tut-splashscreen-with-progress-bar/
Basically, instead of your thread it starts an ASyncTask, you pass a reference to your progressSpinner into the ASyncTask and this will update it as the thread is downloading resources (or whatever you want to do).
Here is a complete tutorial on how to get it done. I've used this one myself with great results.
http://www.barebonescoder.com/2010/04/a-simple-android-splash-screen/