I want to set the first value of the counter as "select your choice", and then display the data from the server one solution * creates another list of arrays and in this list contains the value "select your choice" and combine these two and install on the spinner. how can i achieve this please help me ... (using cursor ????)
Spinner spinner;
private JSONArray result;
ArrayList<String> allNames = new ArrayList<String>();
spinner.setPrompt("...Select the Vehicle Number...");
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String vno = spinner.getSelectedItem().toString();
}
spinner data acquisition method
JSONArray array = jsonObject.getJSONArray("Spinner value");
for (int i = 0; i < array.length(); i++) {
JSONObject job = array.getJSONObject(i);
String name = job.getString("spinner_data");
allNames.add(name);
}
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>
(MainActivity.this, android.R.layout.simple_spinner_item, allNames);
spinner.setAdapter(dataAdapter);
source
share