Office Hours — Today, August 2

Tuesday, July 31

Aug 2
9:55 AM
Mark M.
has entered the room
Mark M.
turned on guest access
10:00 AM
Bruce F.
has entered the room
Mark M.
howdy, Bruce!
how can I help you today?
Bruce F.
Good morning.
I currently have a standard ImageButton which triggers a DatePicker dialog. I’d like to mimic the behavior on some travel apps like Kayak which display a default day of the week/month/day of month on a rectangular square button, and of course update the display on the button based on user choices. Your suggestions?
Mark M.
um
are you saying that you want to replace the ImageButton with the "rectangular square button"?
Bruce F.
yes
Mark M.
and what specifically is the problem?
Bruce F.
Getting the text on a Button/ImageButton
Mark M.
call setText() on a Button to change the caption
there is no text on an ImageButton
Bruce F.
The text needs to be formatted, with different sized fonts
Mark M.
you have two options
1. Use SpannableStringBuilder and appropriate spans to do the formatting (see the Rich Text chapter)
2. Create a snippet of HTML formatted as you wish, then use Html.fromHtml() to get a Spanned
10:05 AM
Mark M.
the results of either of those can be passed to setText()
here is a somewhat dated list of the undocumented list of tags supported by fromHtml(): http://commonsware.com/blog/2010/05/26/htm…
Bruce F.
Thank you.
Mark M.
if you have another question, feel free to ask -- not exactly a crowded room today
Bruce F.
I’d like to provide users with a maximum two line EditText, with the enter button causing a tab to the next EditText. Xml properties maxLines and actionDone aren’t accomplishing it for me.
Mark M.
hmmmm
what is happening when you press Enter (or the action button) on the 2nd line?
10:10 AM
Bruce F.
on 2.1 it works - goes to the next edit text, on Gingerbread it starts a new line without increasing the sized of the edittext box.
I didn't realize it worked on 2.1 until this moment when I tried it on the emulator.
Mark M.
short of trying an InputFilter, I am not sure what else you can do
Bruce F.
I'll try it then.
10:15 AM
Bruce F.
Thanks. Here's another: I have three tabs, but the header of one is elipsized by the system. There is plenty of space between the tabs in the action bar. I’d like to use it rather than truncate a tab label.
Mark M.
any chance you can post a screenshot, so I can see what you are referring to?
Bruce F.
Mark M.
well, there's no space between the tabs -- it's that the tabs are equal size
I do not think that the tab size can be adjusted, but you are welcome to try setCustomView() rather than setText() to see if supplying your own TextView can somehow fix matters
10:20 AM
Bruce F.
thank you.
Another: I'd like a two-line edittext to have the same vertical dimension as a button, and I'm confused about the relationship between sp and dp. Is there a way to ensure that across devices?
Mark M.
there is no relationship between sp and dp
10:25 AM
Mark M.
sp is based on the default font size, as set by the manufacturer and possibly adjusted by the user in Settings
dp is based on screen density
are the EditText and the Button side-by-side?
Bruce F.
yes
Mark M.
I'd consider wrapping them both in a RelativeLayout
set the EditText to have your desired sp-based height
have the RelativeLayout use android:layout_height="wrap_content:
(give or take a ")
have the Button be anchored to the top and bottom of the RelativeLayout
that way, the EditText will dictate the size of the Button
since the EditText will be taking other things into account beyond font size (e.g., line spacing, border)
10:30 AM
Bruce F.
Thank you. And since no one else is in line...
I think the early (pre-honeycomb?) appearance of the spinner is large and obtrusive for my purposes, and I’m thinking of subclassing it to convert to the lower right triangle thingy. Good/bad idea? If I go for it, should the triangle just be a custom button?
Mark M.
AFAIK, you should not need to subclass it
what makes a Spinner is its background
the background is different in the Holo theme set
10:35 AM
Mark M.
that's the GitHub repo for a guy trying to backport all of Holo
Bruce F.
I don't have it in front of me, but I think when I tried it with Sherlock, I got the old look of the spinner
Mark M.
ABS does not backport the Holo theme
you might poke at that HoloEverywhere project and see if it has the resources you need to create a Holo-style Spinner
without necessarily taking on the whole theme backport
Bruce F.
short of that, can I simply change the background of the spinner?
Mark M.
you can certainly try finding the background from a Holo theme, copying it into your project, and using it
10:40 AM
Bruce F.
Thank you very much. That's it from me.
Mark M.
happy to help!
Bruce F.
Bye.
10:50 AM
Bruce F.
has left the room
10:55 AM
Mark M.
turned off guest access
11:10 AM
Mark M.
has left the room

Tuesday, July 31

 

Office Hours

People in this transcript

  • Bruce F
  • Mark Murphy

Files in this transcript