Dialogs # Android Developer says to avoid ProgressDialog to indicate loading, and instead, to put an activity indicator right in the layout.
Progress & Activity # Android Developer discusses activity indicators, but doesn't name the classes used. I've had no luck searching for Android classes with names like ActivityBar, ActivityCircle, or ActivityIndicator.
Where can I find documentation (tutorials, examples, or API documentation) on Android's support for including activity indicators right in my layout, avoiding a ProgressDialog?
Update: full.stack.ex pointed me the right answer.
First, include the following code in the Activity's onCreate() method before invoking setContentView():
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
Next, just before loading (e.g. firing up an AsyncTaskLoader), use this call to make the spinner appear:
setProgressBarIndeterminateVisibility(true);
Finally, after the load is completed, hide the spinner again:
MainActivity.this.setProgressBarIndeterminateVisibility(false);
Bingo! No ProgressDialog required. Making the spinner visible seems to slow down loading considerably in the emulator (it takes minutes instead of seconds), but not on my actual phone. I'm not sure if there's any way to make the spinner use fewer CPU cycles.
It's not really obvious from the documentation that there's a window feature for that.
It's a built-in progress indicator:
Activity.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
developer.android.com/reference/android/app/Activity.html#requestWindowFeature(int)
You're talking about ProgressBar class (I guess): http://developer.android.com/reference/android/widget/ProgressBar.html
Ive tended to use an animated gif image in the past. Good site for generating them is
http://www.ajaxload.info/
Related
Essentially I'm asking what techniques to use in Eclipse/Android Studio to make a UI that looks like the FaceBook UI withtabs on the bottom and their typical action bar on the top with content in the middle.
I've been kind of dealing with this issue for quite some time now and as I have a project deadline coming up figured it was finally time to get stackoverflow's opinion. What would be the best way of creating a social media app that models FaceBook's user interface. By this I am referring to something with the four tabs on bottom and search/back and profile buttons at the top, with some sort of fragment changing in the middle.
The solutions I have currently tried are using a split actionbar by forcing the top into a custom layout and the bottom into an options menu; however, this resulted in giving the options menu the drop down option instead of tabs (if there's a quick fix for this like setting a custom layout to it please lmk because this is my current setup).
For the main content view I originally tried using fragments and then switching between fragments by using functions and buttons inside the fragment class to switch views; however, this required childfragment manager, and for some reason that never worked properly, so instead I ended up switching activities instead of fragments which was horribly slow.
If you guys have any suggestions on how to do this properly please please either tell me how I would go about this, or better yet please show me some very good examples on how to do these things.
Thanks :)
u can use any proto typing tools to create UI . Some tools include Proto.io , Fluid ui etc
I just started my work as an Android developer. My first assignment is to fix several bugs of an App call DailyFinance.
One bug is UI related, if you click a button on a certain page, a dialog will pop up, but the dialog is not displayed properly. My question is how can I locate the code (xml layout file as well as activities) related to the dialog quickly in the codebase which I am not familiar with?
Couple approaches come in mind:
Search for any text that displayed on the target dialog.
Search button text and locate the xml layout file that that contains the button which launch the target dialog
Once find the xml layout file, determine the button 'id' as xxxxx, then you can further search for source contains references to 'R.id.xxxxx'
Set breakpoints on methods in files that implement the dialog. So maybe search for dialog and then put breakpoints inside the dialog. See it it gets hit when your dialog gets pulled up. Or just see where the layouts are set in files that have the word dialog in them. look for R.layout.someLayoutName.
One other suggestion is for some difficult layouts where its tough to see whats going on you can use the HierachyViewer to see the runtime view layouts: http://developer.android.com/tools/help/hierarchy-viewer.html Its worth running on your app to see the structure of the layouts at runtime which is often hard to see these relationships in the layout files before they have been inflated.
BTW, I was a student of CS and the biggest mistake I ever made was not to learn the debugger inside and out. Its without a doubt the most powerful ally you have to learn as well as fix bugs. If you think about it, code really is only an abstraction until you see it running inside the debugger.
I have an AlertWindow that has input fields for registration purposes (looks similar to VPN settings in ICS). The form requires network input to be validated, so it can take a bit of time - and I'd like to add a progress meter (actual progress won't be known).
I'm not sure what is the best way to go about it. I can put one into the ActionBar, but the AlertWindow dims out the whole screen, including the ActionBar when it comes up. Other ways include making a giant progress spinner on top of the whole activity, but I don't like how that would look.
Perhaps I won't need one, and just disabling & changing the text on the register button to 'checking...' or some sort would do?
Any input is welcomed.
I've went ahead and gave the button a different text while it is doing its work.
There is usually an 'indeterminate' state for progressbar controls.
Check this MSDN guideline for different uses of progress bars.
I am looking for a class that implement a horizontal slider bar like the one on the "lock" screen. In other words, user must slide the bar from left to right to run an activity. Thank you so much for your time.
Internally, Android uses a class called SlidingTab for this (the main lockscreen is in a file called LockScreen.java. As with all Android core code, it's Apache licensed. At the risk of sounding like a broken record here on SO, download the AOSP and read through the code whenever you have a "how did the Google folks do x?" type of question (or even when you don't; there's some good stuff in there).
Maybe a Seek Bar might help you towards a solution to your problem. If this works for you let me know, because i am interested in a solution to that as well. Thanks
The link is the developer document for that feature.
Here is an example that extends a horizontal ProgressBar so that the user can set the "progress" by sliding left/right. It's actually quite straight forward, it just overrides the onTouchEvent() method, does some minor mathematics and sets the progress value depending on the TouchEvent's X coordinate.
I ran into an interesting situation with using a ProgressBar in an App Widget... The documentation (http://developer.android.com/guide/topics/appwidgets/index.html) says that ProgressBar is a supported widget class...
I have no problem getting the ProgressBar to display in my App Widget but the problem is that I want it to only be displayed as visual feedback to the user when background processing is happening.
On ImageViews I do this via RemoteViews.setViewVisibility() and everything works fine. However, with ProgressBar I get an exception saying that ProgressBar can't use this method.
Is this intentional or is this a bug? Is there any way to workaround this problem?
An even simpler idea, is to put the progress bar inside some container (say a linear layout) and show/hide the container.
It might be a bug. There's a particular annotation (#RemotableViewMethod) you need in the Java source code of Android itself to mark a method as being available via RemoteViews. View has this for setVisibility(), but ProgressBar overrides that method and does not have the annotation on its own edition. If #RemotableViewMethod is not inherited, and the override "undoes" the annotation, that would explain the symptom you see.
A workaround is to use two app widget layouts and choose the one you want (with or without ProgressBar) when you create your RemoteViews object when updating your app widget.
I'll make a note to try to replicate this and, if I see the same thing, I'll post an issue on it on the Android issue tracker.