There is a spinner that is formed using a SimpleCursorAdapter

//Формируем столбцы String[] from = new String[]{db.CATEGORY_TABLE_NAME}; // создаем адаптер и настраиваем список Log.d(Constants.LOG_TAG, "ChangeTask - spinnerInstall - Создаем адаптер и настраиваем список"); scAdapterSpinner = new SimpleCursorAdapter(ChangeTask.this, android.R.layout.simple_spinner_item, null, from, new int[]{android.R.id.text1}, 0); scAdapterSpinner.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //Присваиваем спинеру Адаптер spinner.setAdapter(scAdapterSpinner); 

I need to specify the default position, spinner.setSelection () - does not work, worked with Aray Adapter, but not here. How can I implement a default Spinner installation if it is configured using a SimpleCursorAdapter?

    1 answer 1

    Understood himself. The bottom line is that the line spinner.setSelection (num); must not be installed immediately after spinner.setAdapter (scAdapterSpinner); and in the place where the adapter sets the cursor

     //Присвоили адаптеру курсор scAdapterSpinner.swapCursor(cursor) //Установили в нужную позицию spinner.setSelection(num);