Spinner in header/title bar

joneden

Active Member
Licensed User
Longtime User
Hi,

I've been looking for a way to have a menu as a spinner control in the title bar (while retaining the title bar's normal functionality and appearance).

I want to do it the same way that it appears in the google currents software.

I've seen the SliderMenu class but that is a slider not a spinner and in addition it means making a fake title bar which I wanted to avoid doing (principally to avoid mucking around with making skins compatible etc).

Any help much appreciated.

Cheers,

Jon
 

joneden

Active Member
Licensed User
Longtime User
Sure, see below. In that shot from the play store you can see that the title appears to be a standard with an icon, then the spinner, then on the right the JB 3 dots for extras.

Or do you think that is a constructed fake title?

Regards,

Jon
 

Attachments

  • unnamed.jpg
    unnamed.jpg
    48.9 KB · Views: 458
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Hi,
the title bar's normal functionality and appearance).

That does not mean much to me. I have a few dozen of apps and the title bar appearance is not really consistent. A lot of them has no title bar at all. Moreover, each manufacturer creates its own theme and changes the system drawables. When I run an app on my phone and the same app in the emulator, I have a different title bar.
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
I looked at the other two and they look good but don't do what I wanted.

I've modded the ActionBar lib to remove the Text element and add in it's place a Spinner object.

The issue that I'm having at the moment is tying the spinner's click event back into a sub on the original module. I've got the following code in the Initialize function:

B4X:
Dim Action As typAction
      Action.Initialize
      Action.Module = abModule
      Action.OnClickSub = uxMenuSpinnerOnClickSub
      uxMenuSpinner.Tag = Action
      Dim r As Reflector
      r.target = uxMenuSpinner
      r.setontouchlistener( "spinner_touch")

I then have the following sub
B4X:
Private Sub Spinner_Touch(ViewTag As Object, Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
   If Action = 1 Then   '= UP
      If SubExists(abModule,uxMenuSpinnerOnClickSub) Then CallSub3(abModule,  uxMenuSpinnerOnClickSub,  2, "    Sync now")
   End If
End Sub

This works although at the moment I don't have any clue as to how to work out which the clicked row in the spinner was. If I know that then I can pass the correct data back to the proper spinner handler.

Any thoughts please?

Best regards,

Jon
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
You did it the wrong way. The class doesn't need to be "modded". Add your spinner from the Activity code like this:
MyActionBar.AsPanel.AddView(MySpinner, Left, Top, Width, Height)
So your spinner is an activity view and you can handle its events as usual.

If you want this spinner in every activity, create a class that initializes the ActionBar and adds the spinner. Then, make an instance of this class in every activity instead of creating an instance of the ActionBar class.
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
Ah, many thanks for that - I'll look into it over the weekend.

Newbies eh? :)

Thanks for your help.

Regards,

Jon
 
Upvote 0
Top