I put entries in spinner via XML.
Now i am want to insert a item on first index of spinner by pragmatically.
is it possible?
ddlParkingType = (Spinner) findViewById(R.id.ddlParkingType);
TextView tv=new TextView(this);tv.setText("All");
ArrayAdapter<String> adapter=(ArrayAdapter<String>)ddlParkingType.getAdapter();
adapter.add("Alll");
Try using ArrayAdapter.insert(T object, int index) as:
adapter.insert("New Value",0);
adapter.notifyDataSetChanged();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With