1

I would like to use the Spinner as view-switching controller at Action Bar in my Android app, just like the native mail app (see part #2 at Android Common App UI).

So far I have managed putting the Spinner in the action bar and populating it with array of strings (see screen shot here) by looking at the example code at Android Developers.

My questions are:

  1. How can I hide the activity name "MyAcitivity" from the action bar so the Spinner gets more place?
  2. How can I make Spinner displaying two lines, one for the title and other for subtitle? Just like in the native mail app.
  3. Why is the item text in the Spinner black and not white as the rest of the text in action bar?

I'm developing for Android version 4.0 and later.

Ismar Slomic
  • 5,315
  • 6
  • 44
  • 63

3 Answers3

0

1.How can I hide the activity name "MyAcitivity" from the action bar so the Spinner gets more place?

in order to remove this title you should edit the activity tag in manifast to android:label=" " do this in every activity you wish for

3.Why is the item text in the Spinner black and not white as the rest of the text in action bar?

you can create style for the text color like theme.holo.light and apply this theme to your activity

Tomer Mor
  • 7,998
  • 5
  • 29
  • 43
0

How can I hide the activity name "MyAcitivity" from the action bar so the Spinner gets more place?

Call setDisplayShowTitleEnabled(false) on the ActionBar for this activity.

How can I make Spinner displaying two lines, one for the title and other for subtitle? Just like in the native mail app.

Create layouts that have more than one line in them that you use with your SpinnerAdapter.

Why is the item text in the Spinner black and not white as the rest of the text in action bar?

Probably you need to use getThemedContext() on ActionBar to get the Context to use with your SpinnerAdapter constructor.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • CommonsWare, thanks a lot. Your answers solved question 1) and 3). Could you please give an example on creating layout with more than one line to use with SpinnerAdapter at question 2? Thanks in advance! – Ismar Slomic Jul 31 '12 at 16:33
  • @IsmarSlomic: Use a layout file with more than one `TextView` in it. Teach your adapter to populate the second `TextView`. This is no different than handling multiple widgets in the row of a `ListView`. The details vary by adapter class, but there are countless examples online. – CommonsWare Jul 31 '12 at 16:47
0

1) How can I hide the activity name "MyAcitivity" from the action bar so the Spinner gets more place?

If you are using a standard theme, you can just look for the "noTitleBar" version and add it

android:theme="@android:style/Theme.Light.NoTitleBar"

FYI: check this link, it contains more detailed info

2) How can I make Spinner displaying two lines, one for the title and other for subtitle? Just like in the native mail app

I really dont get what you wanna do. If u need a text above and one below a spinning icon, you can just create a linear layout (a vertical one) adding inside of it the 3 elements

3) Why is the item text in the Spinner black and not white as the rest of the text in action bar?

You can modify every element in your layout by editing the style you are using.

FYI: basic theme in android

Community
  • 1
  • 1
sataniccrow
  • 372
  • 2
  • 7