views:

70

answers:

1

Good Morning,

I got my app to install on the Backflip and started testing it. On the emulator everything appeared ok but on the Backflip there are a few notable differences.

I have edittext boxes which on the emulator automatically vary in size to accommodate the text. The text is a number, the max being two digits, i.e., 1-99. On the Backflip the edit boxes seem to be a fixed width and that width is larger than needed. Consequently some of the edittext boxes go past the end of the screen and can't be used or seen. This doesn't happen on the emulator.

I also have spinners. One set of spinners is created using android.R.layout.simple_spinner_dropdown_item populated by an array from array.xml. These spinners have the radio button showing and they work on both the emulator and the Backflip displaying a white background with black text.

The other spinner is created using int layoutID = android.R.layout.simple_spinner_item and is populated with strings from the database using an ArrayAdapter. This spinner displays ok on the emulator with a white background with black text. On the Backflip however, it displays the white background but with white text making the list essentially impossible to see. The list is populated because when I press on an item the background color changes to red, the text is white, and the program works ok.

My question is: Are these discrepancies peculiar to the Backflip or am I doing something wrong in the code? I'd hate to think all devices come with peculiarities that require workarounds. Hopefully I'm doing something wrong and hope someone can point out what it is. I'll post any code someone wants to see but right now I don't know what to post. Thanks.

[Edit] I should add that when I use android.R.layout.simple_spinner_dropdown_item for the other spinner the text shows up ok but I now have the radio buttons which I don't want.

+2  A: 

I should add that when I use android.R.layout.simple_spinner_dropdown_item for the other spinner the text shows up ok but I now have the radio buttons which I don't want.

Do not use android.R.layout.simple_spinner_item for the drop-down item, since that is not what it is supposed to be used for. Use android.R.layout.simple_spinner_dropdown_item, or copy that layout into your project (in data/res/layout/ in one of your SDK platform directories), modify it to suit, and use it.

As to why the behavior difference, Motorola, for the MOTOBLUR handsets, appears to have modified some of the stock resources to fit their needs. While those resources will generally work, they will only have been tested for things they are supposed to be used for. Relying on android.R.layout resources will generally work, but only if those resources are used as intended. If you want full control, make your own copy.

CommonsWare
I agree - it's usually best not to rely directly on the android.R.x files, and instead to make a copy of them which you use. This is particularly the case for graphics, as someone might have a custom theme which replaced many of the default colours and icons. These could then clash badly with your own images.
Steve H
CommonsWare, Thanks. I'll override the spinner and eliminate the radio buttons. Two questions though: What is the purpose behind simple_spinner_item then? Also, in your last sentence you say to make your own copy. Are you talking about overriding the EditText?
eric
Steve H, Thanks. What do you mean by "make a copy of them"?
eric
`simple_spinner_item` is the layout what goes in the `Spinner` itself, not the drop-down. To make a copy of a resource, find it on your dev machine (see my original answer) and copy it into your project. All of the `android.R` resources (or at least most of them) are in your SDK.
CommonsWare
CommonsWare, Thanks! Sounds like it's as simple as a copy and paste from the android.R to constants in the program.
eric