views:

61

answers:

1

Hi

My spinner control is displaying fine no problem. When someone is in create mode they are able to selected a value which I am able to record and store in my database.

But I have a problem when someone is in edit mode and I want to display the list but have one of the items (say the third) selected. I can't see how to do that. All the tutorials talk about how to populate the spinner but not how to preset one as being selected.

this.ddlCategory = (Spinner)this.findViewById(R.id.add_edit_place_ddlCategory);
    ArrayAdapter adpt = new ArrayAdapter(this, android.R.layout.simple_spinner_item, categories);
    adpt.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    this.ddlCategory.setAdapter(adpt);

Please help Cheryl

A: 

You can use one of the setSelection methods to programatically select a value.

Mayra