3

I have a progress spinner displayed in the menu. I'd like to display a number inside the spinner, how would I go about doing this? Below are some of the code snippets for what I am doing to make the progress spinner work:

public void onCreateOptionsMenu(...) {
    ...
    if (uploadCount > 0) {
        MenuItem updatingMenuItem = menu.findItem(R.id.photo_capture_action_updating);
        updatingMenuItem.setActionView(R.layout.action_progressbar);
        updatingMenuItem.expandActionView();
    } else {
        menu.removeItem(R.id.photo_capture_action_updating);
    }
}

And below is the action_progressbar.xml

<?xml version="1.0" encoding="utf-8"?>
<ProgressBar xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/progressBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">         
</ProgressBar>

Thank You,

Gary Kipnis
  • 722
  • 14
  • 33
  • you can use a relative layout for this with your the textview in background and in front you can have your spinner loading..something like what this user has suggested for loading an image http://stackoverflow.com/questions/18964799/progress-bar-with-image-in-center – NetStarter Dec 23 '13 at 07:54

1 Answers1

3

You can add a textview along with this progressbar,with gravity center and wrap it inside a frame layout. xml-

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/progressBarLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <ProgressBar
        android:id="@+id/progressBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    </ProgressBar>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="14" />
</FrameLayout>

Hope this solves your problem.

nikvs
  • 1,090
  • 5
  • 9