There are few problems that are coming right now, the emulator shows these
messages dont know for which reasons
[2010-04-06 11:10:00 - HelloSpinner] ActivityManager: [1] Killed am start -D
-n c...
[2010-04-06 11:10:21 - HelloSpinner] Attempting to connect debugger to
'com.example.HelloSpinner' on port 8635
[2010-04-06 11:10:39 - Emulator] emulator: emulator window was out of view
and was recentred
The code is,
*public* *class* HelloSpinner *extends* Activity
{
// Here we initiate the spinners and provide a result
*public* *void* onCreate(Bundle savedInstanceState)
{
*super*.onCreate(savedInstanceState);
setContentView(R.layout.*main*);
// We define what we want to show here
String[] *PROJECTION* = *new* String[]
{
People.*_ID*, People.*NAME
*
};
Spinner spinner = (Spinner) findViewById(R.id.*spinner*);
spinner.setOnItemSelectedListener(*new* MyOnItemSelectedListener());
Cursor cur = getContentResolver().query(People.*CONTENT_URI*, *null*, *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);
} // The create method ends
*public* *class* MyOnItemSelectedListener *implements*OnItemSelectedListener
{
*public* *void* onItemSelected(AdapterView<?> parent,
View view, *int* pos, *long* id)
{
Intent intent = *new* Intent(Intent.*ACTION_CALL*);
Cursor cursor = (Cursor) parent.getAdapter();
*long* phoneId = cursor.getLong(cursor.getColumnIndex(People.*
PRIMARY_PHONE_ID*));
intent.setData(ContentUris.*withAppendedId*(Phones.*CONTENT_URI*, phoneId));
startActivity(intent);
}
*public* *void* onNothingSelected(AdapterView<?> parent)
{
// Do nothing.
}
}
}
--
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.