0

In the spinner,at present the values gets loaded automatically,but now we need the spinner to be by default empty,and then values must then get loaded,when the users clicks on the spinner.

                                                                                                                                                                                                       public void requestSucceed(Response response) {
    // TODO Auto-generated method stub
    Log.i("Response Code ", response.getResponseCode() + "");
    if (response.getResponseCode() == 0) {
        List<String> list = new ArrayList<String>();
        list.add("Select Product");
        deliveryBoys = response.getDeliveryBoy();
        Log.v("Size is ", "" + deliveryBoys.length);
        for (int i = 0; i < deliveryBoys.length; i++) {
            list.add(deliveryBoys[i].getDistId());

        }
        Log.v("Size is ", "" + list.size());

        ArrayAdapter adapter = new ArrayAdapter(this,
                android.R.layout.simple_spinner_item, deliveryBoys);
        deliveryPerson.setAdapter(adapter);enter code here
Deepi
  • 188
  • 1
  • 1
  • 10

2 Answers2

0

is it possible have a spinner that loads with nothing selected

Only if there is no data. If you have 1+ items in the SpinnerAdapter, the Spinner will always have a selection.

Spinners are not designed to be command widgets. Users will not expect a selection in a Spinner to start an activity. Please consider using something else, like a ListView or GridView, instead of a Spinner

EDIT

BTW, I forgot to mention -- you can always put an extra entry in your adapter that represents "no selection", and make it the initial selected item in the Spinner.

check : https://stackoverflow.com/a/4726649/1838457

Community
  • 1
  • 1
Android Developer
  • 1,039
  • 1
  • 9
  • 33
  • 1
    There is nothing in copying and pasting someone's answer to another question without modifying. Instead you can comment that link in the OP. – Sankar V Apr 22 '13 at 06:02
0

You can have a dummy value (For ex: Select Delivery Boy) as the default one. So, the user can select a value by clicking the spinner.

Sankar V
  • 4,794
  • 3
  • 38
  • 56