ActionBar Sherlock Progress Bar in Icon space - android

I am using an Action bar in my project. I am displaying a progress bar via the below approach.
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setProgressBarIndeterminateVisibility(true);
However, what I'd really like to do is replace the left most image icon with the progress indicator when arbitrary background processes run and then returns the usual icon when complete.
Can anyone tell me the steps needed to replace this icon with a functional Progress indicator. It only needs to be an intermediate one.

Looks like you can find some suggestions here: Android: dynamically change ActionBar icon?.
Specifically, you can access the icon by using
Activity.findViewById(android.R.id.home)
And then just set and re-set the icon as needed.

You need to build a custom layout for this and use actionbar.setCustomView(yourcustomlayout);
In your custom layout have an imageView(which is your app icon) and progress bar(initially which is set to invisible).
When running the background process just set the visibility between image view and progress bar.

Related

How to create progress indicator without filling color?

I have a viewpager with many images in my app. Below viewpager I need to show a progress indicator as shown in image. whenever the image is changed the dark blue part also will change its position accordingly. I am not sure which component to use here. Does it require a custom component? Will customizing progress bar work? Any help would be appreciated.

How to make Circular Logo in Action Bar?

My requirement is to make Circular Icon to ActionBar. I used custom view to display circular image(you can see in the screenshot.) I want to use Home icon(In this case, green android icon) as a circular image. How can I make Home icon as a Circular Image??
Note: In my case I'm downloading images from Server and setting it to ActionBar using setLogo() or setIcon() method.
Make the image default logo of your application.
Change it in the manifest file or the drawable folder.
Action bar logo is mostly your application logo by default. So either Change your application logo to circular or whatever. If you want to change the app icon (logo). Use setLogo(int) or setLogo(Drawable) method of ActionBar. Don't forget to call setDisplayUseLogoEnabled(true)

Indeterminate progress in Android Activity

I am trying to replicate the experience found when you are uninstalling an app in ICS. Specifically the indeterminate progress indicator under the title bar. I have tried using requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS) and the various methods on Activity but to no avail. It instead shows a spinning progress bar in the top right hand corner of the screen/title bar. Am I missing something simple here? Or is this completely custom?
Here is the code I am using:
#Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setProgressBarIndeterminate(true);
setProgressBarIndeterminateVisibility(true);
}
You are using the ActionBar indeterminate progress bar, but you are looking for a ProgressBar View.
You can create the View programmatically or add it to a layout file like --
<ProgressBar
android:id="#+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:indeterminate="true" />
Typically, you can decide when it is shown by calling .setVisibility(View.VISIBLE) to show and .setVisibility(View.GONE) when you are done.
If you have a minimum API of 11 and set your activity or app theme to #android:style/Theme.Holo you will get exactly that ProgressBar shown in your image.
If you want a similar effect on pre-API 11 devices, check out HoloEverywhere
Disclaimer: #iagreen's answer is still the right one -- to get layout similar to the one in uninstall activity your best option is to just use it in a layout, not rely on window features)
But you were on a right track with windows features, you just mixed two of them up.
See, this:
setProgressBarIndeterminate(true);
requests the window's [horizontal] progress bar to be indeterminate. And this:
setProgressBarIndeterminateVisibility(true);
shows the window's indeterminate progress bar -- thing is, it's a completely diffrerent view.
To clarify things further, this gets you a horizontal indeterminate progress bar shown at the top of the window
requestWindowFeature(Window.FEATURE_PROGRESS);
setProgressBarIndeterminate(true);
setProgressBarVisibility(true);
and this gets you a spinner-style progress bar in the actionbar
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setProgressBarIndeterminateVisibility(true);
That's a horizontal progress bar in the image, the Action Bar indeterminate progress bar is a Spinner style. You'd either need to make a custom view for the action bar, or put it as a view in your main layout. You can hide the action bar and make a custom header for a particular activity. Just use the Spinner style indeterminate progress bar, it's what everyone expects to see in the Action Bar.

Android Progressbar not allowing to switch tab

I have two tabs in my app.First tab displays the details of user and the second tab displays the applications that are installed on his device.I have used Package manager for getting the installed apps and it is running ins background thread. If the user clicked the second tab before the background thread completes I want to show a progressdialog.But the problem is if progressdialog is displayed on the screen user can't switch to next tab.Is there any way to solve this issue.Thanks in advance.
Progress dialogue by default works in dialogue mode and freezes any operations until the progress bar is gone.
I had faced issues with controlling progress bar (though my requirements were more than yours like customizing looks and showing/ hiding/ freezing bar at will), so I ended up creating a custom progress bar.
It is pretty simple
Create 2 straight straight bars, one black and other of any color (if you want something more fancy, it is upto you)
Add the bars to drawable and then to your layout xml in hidden mode. The colored bar exactly on top (superimpose) of black bar
Now where you want to show the progress bar, make the black bar visible first, and adjust the width of colored bar (on top of black bar) as per the progress.
This will give you proper functionality of the progress bar.
As you are playing around only with imageviews, you have full control over when to show or hide the bar. Also by default it will not freeze the view. You can freeze at will by capturing onTouch event.

Android ABS shows large ProgressBar

I use setSupportProgressBarIndeterminateVisibility(true); in my activity to show a Indertiminate ProgressBar. This shows a large ProgressBar in the ActionBar. I want to use a small progress bar . How can i do this ?
Kind Regards,
You need to create a style in order to get a small progressbar.
See this link, where explains how to change the Default Indeterminate Progress Size in ActionBarSherlock
http://thanksmister.com/2012/03/30/change-default-progress-actionbarsherlock/

Categories

Resources