android - My App Spinner is getting in last -


hey guys want set spinner default text in top select category shown last when fetch data data base want set text on top of items

my code is

 private void loadspinnerdata() {     socialdatabase db = new socialdatabase(getapplicationcontext());     arraylist<string> lables = db.getalllabels();     lables.add("select category");     arrayadapter<string> dataadapter = new arrayadapter<string>(this,             r.layout.spinner_text, lables);     dataadapter             .setdropdownviewresource(r.layout.spinner_text);     txtspinner.setadapter(dataadapter);  } 

this output

[show[1]

want this

want

please me

try line of code

replace

 lables.add("select category");  

with

 lables.add(0, "select category"); 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -