1

またはアプリケーションのSpinner後、選択したアイテムを同じままにしておく必要があります。項目は、を使用して sqlite データベースから取り込まれています。どうすればこれを達成できるか教えてください。onRestart()onResume()SpinnerArrayAdapter

String myString = (String) myspinner.getSelectedItem();` //the value you want the position for
    ` @SuppressWarnings("unchecked")
    ArrayAdapter<String> myAdap = (ArrayAdapter<String>) myspinner.getAdapter(); //cast to an ArrayAdapter
    int spinnerPosition = myAdap.getPosition(myString);
    //set the default according to value
    myspinner.setSelection(spinnerPosition);
4

2 に答える 2

0

you can save the position of spinner in onSaveInstanceState() and retrive the spinner position from onRestoreInstanceState (). you can use a common global variable for update the spinner position.

and use this variable in onResume() method . hope that it will work

check it

于 2013-03-12T08:09:27.953 に答える