How Do I Change The Layout Of The Items in the Spinner Control?

by Mark Murphy » Mon, 10 Nov 2008 16:20:39 GMT


Sponsored Links
 


If the revised layout is the same for all of them, give the revised 
layout to the adapter constructor. You may need to use the 
ArrayAdapter(Context context, int resource, int textViewResourceId, T[] 
objects) if your layout is more than a single TextView.

If your revised layout varies by item or needs to shift on the fly, you 
will probably need to subclass your adapter and implement getView() to 
return the View you want for each row. If you visit AndroidGuys.com and 
search "Fancy ListViews", you'll find a long list of blog posts on that 
topic, though some are from the M5 SDK and will need tweaks to work on 
the current one.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 1.4 Published!

--~--~---------~--~----~------------~-------~--~----~



How Do I Change The Layout Of The Items in the Spinner Control?

by Matthias » Mon, 10 Nov 2008 16:37:03 GMT


 I've got my first basic app working, but I need the text inside my
spinner widget to lay out in a different way (different gravity,
different text style, etc.) How can I do this? Is there a way to give
the item a different layout setup with the Array Adapter?

Example:

ArrayAdapter myArrayAdapter = new
ArrayAdapter.createFromResource(this, R.array.myArrayResource, [change
something here?]);

If so, what do I change it to? I've tried giving it a basic layout
with a TextView and the app freezes on me. Is there some kind of
format I need to be mindful of?

Or do I need to do something with the spinner itself?

Matthias

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


How Do I Change The Layout Of The Items in the Spinner Control?

by Matthias » Mon, 10 Nov 2008 22:16:29 GMT


 You are so totally the man!

For anyone else reading this, I created a new view called
"my_spinner_view.xml" with the following xml:

<?xml version="1.0" encoding="utf-8"?>
<TextView  xmlns:android=" http://schemas.android.com/apk/res/android" ;
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textSize="14pt"
                android:id="@+id/spinnerTarget" />

and my ArrayAdapter code looks like this:

ArrayAdapter myArrayAdapter = new
ArrayAdapter.createFromResource(this, R.array.myArrayResource,
R.layout.my_spinner_view);

And my spinner text is formatted exactly the way I want.






--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Video and Audio Stream

Hi All,
        I am working on video phone application over android. I am
very new to android. I have some question :
        1.To show live call video of both endpoints which package and
class should be use. And what is a process to do it.
        2. To Handle audio stream on call and what is process to do
it.

Thanks
Chetan Chauhan



-- 

2. Refresh the Home screen "Widgets" menu.

Hi,

In my application, I have widgets that are disabled in the manifest.
I enable those from code, using the
PackageManager.setComponentEnabledSetting method.  This change does
not take effect until I restart the device.

Is there a way to refresh the Home screen Widgets menu without a
reboot?

In the Android source, I see that the PackageManagerService uses the
ActivityManagerNative class to broadcast a protected intent.  I'm
hoping there is a public way of doing this.

Thanks.

-- 

3. Fwd: CTS in Eclair

4. Increase alpha values of pixels on Bitmap/Canvas?

5. Wndows View Properties.

6. Build your Android application in Chrome browser

7. modify the RecentTasks List