Spinner: text vs value

by droidin.net » Wed, 05 Aug 2009 03:12:19 GMT


Sponsored Links
 I declare my Spinner in the following manner (it's very static so I
have 2 string arrays in array.xml for titles and values)

<Spinner android:id="@+id/searchCriteria" android:entries="@array/
searchBy" android:entryValues="@array/searchByValues">
</Spinner>

I expect spinner.getSelectedItem() to return an array [title, value]
but in fact it returns just a title String. Is it ignoring
android:entryValues? How do I get a value, not a title from it? Is
this doable with XML only or do I need to create adapter and do it
programmatically?

Thanks,

Bo
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Mistake in official Sample ?

http://developer.android.com/resources/faq/commontasks.html#opennewscreen

Scroll down to "Returning a Result from a Screen" and look at code sample :

Shouldn't that be requestCode to switch() ?

// Listen for results.
protected void onActivityResult(int requestCode, int resultCode, Intent data){

    // See which child activity is calling us back.
    switch (*resultCode*) {

        case CHOOSE_FIGHTER:
            // This is the standard resultCode that is sent back if the

            // activity crashed or didn't doesn't supply an explicit result.
            if (resultCode == RESULT_CANCELED){

                myMessageboxFunction("Fight cancelled");
            }

            else {
                myFightFunction(data);

            }
        default:
            break;

    }
}

-- 

2. layout inflator

I am implementing a ListAdapter and in getView, I am returning 

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    switch (position) {
    case 0:
        if (title == null) {
            title = View.inflate(mContext, R.layout.main_settings_title, 
parent);
        }
        return title;
    }
    return null;
}

inflate is throwing a UnsupportedOperationException

The resource is posted below. What am I doing wrong?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/menutitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#444444"
android:gravity="center_horizontal|top" 
android:text="Settings"
android:textColor="#eeeeee"
android:textStyle="bold"
android:shadowColor="#000000"
android:shadowRadius="3."
android:shadowDx="3.0"
android:shadowDy="3.0"
android:textSize="7pt"
android:paddingBottom="20dip"
android:paddingTop="20dip"/>
</LinearLayout>

-- 

3. Regarding Scale Animation in 2d graphics

4. RatingBar onClick not being recognized in AlertDialog

5. GridView disappears...

6. LVL suggestion

7. VOOT - WTB : ipod touch 4thgen 8gb