Cheers for the answer .....
I did not do what I needed, but I managed to solve my problem as follows.
First I created an array inside my activity, not strings.xml.
String[] NoCore_Array = new String [5]; { NoCore_Array[0] = "1"; NoCore_Array[1] = "2"; NoCore_Array[2] = "3"; NoCore_Array[3] = "4"; NoCore_Array[4] = "5"; }
Then I created a counter using ...
Spinner spnNoCore = (Spinner) findViewById(R.id.spinner_nocore);
Then the adapter created using the above array ....
ArrayAdapter NoCoreAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, NoCore_Array); spnNoCore.setAdapter(NoCoreAdapter);
Then set the default adapter position as follows:
//Set Default Selection spnNoCore.setSelection(1);
Then the rest of the spinner code for action ...
spnNoCore.setOnItemSelectedListener(new OnItemSelectedListener(){ public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { //Get item from spinner and store in string conductorSize........ NoCore = parent.getItemAtPosition(pos).toString(); if (NoCore.equals(NoCore1)) { CoreNo = 1 ; } if (NoCore.equals(NoCore2)) { CoreNo = 2 ; } if (NoCore.equals(NoCore3)) { CoreNo = 3 ; } if (NoCore.equals(NoCore4)) { CoreNo = 4 ; } if (NoCore.equals(NoCore5)) { CoreNo = 5 ; } } public void onNothingSelected(AdapterView parent) { // Do nothing. } });
Hope this can help other people who have the same problem with setting the default value to Spinner.
However, the layout of the dialog is not so good when it is done. There are no radio buttons, it just looks like a selection of text with lines separating the sections.