1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to set default value to spinner dropdown in Android?

Discussion in 'Programming/Internet' started by Nuwan Indika, Sep 12, 2018.

  1. Nuwan Indika

    Nuwan Indika Guest

    I need to set the default value text "select your Device" value to my spinner drop-down list, I put it as list item so it acts as a drop-down list items and I hide the drop-down list, because of that I’m getting a blank space in my drop-down.

    How should I do this?


    this is the code I’m used

    mToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);

    /*Setup a Spinner*/
    mToolbarSpinner = (Spinner) findViewById(R.id.spinner_toolbar);

    /*Manage the spinner*/
    mToolbarSpinnerNavigationItems = new ArrayList<SpinnerNavItem>();

    mToolbarSpinnerNavigationItems.add(new SpinnerNavItem("Select your Seebo", R.drawable.deviceonline));

    /*setting the mToolbarSpinnerNavigationItems to list_item_title_navigation.xml*/
    mArrayAdapter = new ArrayAdapter(this, R.layout.list_item_title_navigation,mToolbarSpinnerNavigationItems){
    public View getView(int position, View convertView, ViewGroup parent) {

    // remember to inflate custom layout for spinner item
    // then set anything you want here
    // remember to use convertView.findViewById(), not just findViewById()

    // this is an example
    // inflate layout
    convertView = View.inflate(MainActivity.this, R.layout.list_item_title_navigation, null);
    // get view
    TextView tvText1 = (TextView) convertView.findViewById(R.id.devicetitle);
    ImageView imgIcon = (ImageView) convertView.findViewById(R.id.deviceicon);
    // set content
    // return
    return convertView;

    public View getDropDownView(int position, View convertView, ViewGroup parent) {

    return convertView;


    //setting adapter to Spinner

    Login To add answer/comment

Share This Page