Add ProgressBar while loading UI content - android

I have used Google Place Picker API in my app
So Place Picker takes time to load, so I want to use ProgressBar for a certain time till the api is completely loaded
and is there any way to work with complex UI
for eg my main page contains lots of data and it takes around 5-6sec to completely load it,so is there a way to add progressbar over there also?
please Help i am new to android

Declare your progress dialog:
ProgressDialog progress;
When you're ready to start the progress dialog:
progress = ProgressDialog.show(this, "dialog title",
"dialog message", true);
and to make it go away when you're done:
if (progress != null) {
progress.dismiss();
}

Related

How to display rolling updates on Android and iOS

I have a requirement to display the different stages of a Process in a dialog box overlay on the mobile app such as "Process 1 started" "Process 1 completed" "Process 2 started" and so on until the process is completed.
Essentially, what I'm looking for is scrollable text in an overlay screen appearing as the app receives different notifications(BLE characteristics). No user interaction required. Is there an out-of-the-box dialog box control that I can use? Any other suggestions for such a display?
U can add the DialogFragment and
if(process1.isDone())
{
informationOnDialogFragment
}
if(process2.isDone())
...
But the easiest way is add ProgressDialog
U can set message to ProgressDialog
You can achieve it using simple toast or other innovative libraries like:
1. EFInternetIndicator
2. FTIndicator
You can use Progress Dialog . With progress.setCancelable(false); you can make it so the user can`t navigate away from the dialog.

Add loading page until my application work in Android

I am developing an app similar to Shazam but with video.
My app have to process a video and in this time the display become all black. Is it possible to implement a "loading"? So while the phone elaborate the video I don't see black screen but a sort of loading page. Any suggestion? Thank you
You can do it simply by using a ProgressDialog:
ProgressDialog dialog=new ProgressDialog(context);
dialog.setMessage("message");
dialog.setCancelable(false);
dialog.setInverseBackgroundForced(false);
dialog.show();
And when you done with your process call:
dialog.hide();

ProgressDialog#setIndeterminate(false) not working

I'm trying to display a determinate progress dialog with a bar, however, I can't get it to working. Here is how I create it:
dialog = ProgressDialog.show(from, "Posting...", "Uploading...");
Then on UI thread (calling within runOnUiThread), I'm calling:
dialog.setIndeterminate(false);
However, when I inspect after it (both immediately after setting, and in progress handler afterwards which is invoked independently while uploading a file), it's isIndeterminate() method returns true. I've also tried:
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
But it also didn't change anything (still, indeterminate indicator is spinning instead of a progress bar). I've set it's max to 100, and my progress handler is being invoked with perfectly valid values between 0 and 100, and I'm calling all dialog methods on UI thread, but nothing changes. What am I doing wrong?
You can't change the style of the progress after showing the ProgressBar what you can do is to prepare it first then show it.
progressDialog = new ProgressDialog(this);
progressDialog.setTitle("title");
progressDialog.setMessage("message");
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.show();
OR
dialog = ProgressDialog.show(from, "Posting...", "Uploading...", false);

How to add a image on an event in android

I am new to Android. In my application I want to add an process bar(an image), this should indicate that something is in process and after completion hide this precess bar.
As if i add user detail, On click on add button this process bar should be displayed.
How can i do it, please suggest.
Thanks.
Code I used:
progressDialog = ProgressDialog.show(AddTicketActivity.this, "", "Loading...");
new Thread() {
public void run() {
try{
sleep(10000);
} catch (Exception e) {
Log.e("tag", e.getMessage());
}
progressDialog.dismiss();
}
}.start();
The problem with it is , it is hardcoded sleep(10000) whereas what i want is it to be dependent on how much time my process takes to add or fetch data.
I am not getting where to put code which is executing on onclick of button.
I hope you got my point
Thanks again.
For that you can use either ProgressDialog or ProgressBar.
Now, To display Progress bar and during that perform task in background, you should implement AsyncTask.
In onPreExecute() method, display the ProgressBar or make it visible again like: progressbar.setVisibility(View.VISIBLE);
In doInBackground() method, perform the background task, i.e. add user detail in your case
In onPostExecute() method, just hide the ProgressBar using the progressbar.setVisibility(View.INVISIBLE);
Well if you just want to show an image, you can place it on a RelativeLayout with visibility=gone
and then just control when to show or hide it.
another way is the typical progressDialog in Android
Or use a progress bar (spinning wheel) it's more user friendly and droid friendly .
Take a look at the Form widgets on Eclipse .

Remove process dialog when page starts loading?

I am using a webview in an application and currently when webview starts, a dialog appears showing "please wait, loading" and remains there on screen until every single dot on the web page is loaded. which obviously makes it seem working too slow. Now i want is to dismiss the dialog when webview has something on it and remaining may keep on loading, so that app may become a little more responsive. what should i do....????
Here's a great tutorial on adding a progress bar to the top of your webview:
http://longweekendmobile.com/2011/08/20/custom-progress-view-on-android-webview/
To apply this to your needs, just dismiss the progress dialog prior to the progress reaching 100.
Something like this:
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
if(progress >= 50){
if(progressDialog.isShowing()){
progressDialog.dismiss();
}
}
}
});
Adjust the if statement with 50 to whatever value you want. This code is untested and should just be used to give you the idea.

Categories

Resources