Get the selected item from spinner
<p>I have follow what the rest had stated <a href="http://stackoverflow.com/questions/5787809/get-spinner-selected-items-text">here</a>. However, that seems to be a problem with my coding. Initially, my spinner should have shown the first item in the list when i first arrive at this activity but not it is just empty. Luckily the list is still there when i click on the spinner to make my selection. And also, after i have made my selection, the toast did not show up. I am not sure whether this is the cause of it as it pop out in the DDMS after i have make my selection:</p>

<pre><code>09-07 06:30:06.470: WARN/InputManagerService(50): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@43cbe3b0
</code></pre>

<p><strong>Here is the coding for this activity:</strong></p>

<pre><code>package android.wps;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.view.Gravity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemSelectedListener;

public class locationFinder extends Activity {

WifiPositioningServices wifiPositioningServices = new WifiPositioningServices();

ArrayList&lt;Profile&gt; profileList = new ArrayList&lt;Profile&gt;();
ArrayList&lt;String&gt; profileNames = new ArrayList&lt;String&gt;();
ArrayList&lt;String&gt; mapNames = new ArrayList&lt;String&gt;();

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.locationfinder);

    String[] temp = wifiPositioningServices.GetAllProfileData();

    final Spinner profiles = (Spinner)findViewById(R.id.profileList);

    ArrayAdapter&lt;String&gt; spinnerArrayAdapter = new ArrayAdapter&lt;String&gt;(this,
            android.R.layout.simple_dropdown_item_1line,
            profileNames);
    spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    profiles.setAdapter(spinnerArrayAdapter);

    profiles.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView&lt;?&gt; parent, View view,
                int pos, long arg3) {
            // TODO Auto-generated method stub
            String test = parent.getItemAtPosition(pos).toString();
            Toast toast = Toast.makeText(parent.getContext(), test, Toast.LENGTH_SHORT);
            toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
            toast.show();
        }

        @Override
        public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
            // TODO Auto-generated method stub

        }
    });

    //store all profile data into a ArrayList of Profile objects
    for(int i=0; i&lt;temp.length; i++){
        String[] result = temp[i].split(",");
        Profile profile = new Profile();
        profile.setProfileName(result[0]);
        profile.setOwner(result[1]);
        profile.setMap(result[2]);
        profile.setVisible(result[3]);
        boolean visible = Boolean.valueOf(result[3]);
        if(visible){
            //if visible is true, then add profile name and mac filters into arraylist 
            profileNames.add(result[0]);
            for(int j=4; j&lt;result.length; j++){
                profile.setMacFiltersList(result[j]);
            }
        }
        profileList.add(profile);
    }
}
</code></pre>

<p>}</p>

<p><strong>locationfiner.xml</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;AbsoluteLayout
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
&gt;
&lt;TextView
android:id="@+id/txtPofile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Profile:"
android:textStyle="bold"
android:layout_x="10px"
android:layout_y="12px"
&gt;
&lt;/TextView&gt;
&lt;Spinner
android:id="@+id/profileList"
android:layout_width="245px"
android:layout_height="36px"
android:layout_x="70px"
android:layout_y="12px"
&gt;
&lt;/Spinner&gt;
&lt;TextView
android:id="@+id/counter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:layout_x="0px"
android:layout_y="32px"
/&gt;
&lt;/AbsoluteLayout&gt;
</code></pre>
