Hi,
I am newbie in Android Application Development. I am trying to invoke
a list in spinner can anyone tell me where I am having trouble. Please
help. Here is the code of my application

public class Spinner extends ListActivity
{
        public void onCreate(Bundle savedInstanceState)
        {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
                        String[] PROJECTION = new String[]
                {
                                People._ID, People.NAME
                };
                Spinner spinner = (Spinner) findViewById(R.id.spinner);
                Cursor cur = getContentResolver().query(People.CONTENT_URI,
PROJECTION, null, null, null);
                SimpleCursorAdapter adapter2 = new
SimpleCursorAdapter(this,
                                android.R.layout.simple_spinner_item,
                                // Use a template
                                // that displays
a
                                // text view
                                cur,
                                // Give the cursor to the list adapter
                                new String[] {People.NAME},
                                // Map the NAME column in the
                                // people database to...
                                new int[] {android.R.id.text1});
                                //      The "text1" view defined in
                                // the XML template
 
adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                                spinner.setAdapter(adapter2);

        }

        public class MyOnItemSelectedListener implements
OnItemSelectedListener
        {
                public void onItemSelected(AdapterView<?> parent,
                                View view, int pos, long id)
                {
                        Toast.makeText(parent.getContext(),
                        "The Person is " +
                        parent.getItemAtPosition(pos).toString(),
                        Toast.LENGTH_LONG).show();
                }
                public void onNothingSelected(AdapterView<?> parent)
                {
                        // Do nothing.
                }
        }
}

Please help..

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to