Spinner does not show selected value

后端 未结 25 1350
-上瘾入骨i
-上瘾入骨i 2020-12-03 13:16

I have implemented the spinner by populating the array list through database.I can get and show the array list in my spinner array adapter but if I select the item in spinne

25条回答
  •  攒了一身酷
    2020-12-03 13:49

    Problem:

    Spinner displays neither the default nor selected item value. But drop-down menu items are show when selected.

    Cause:

    Background and text color both being white!!!

    Solutions:

    xml(Preferable):

    Write a custom layout for a spiner item and use it instead of the default,android.R.layout.simple_spinner_item.

    How to change spinner text size and text color?

    Code(Less reliable):

    your_spinner_instance.setOnItemSelectedListener(new Spinner.OnItemSelectedListener(){
        public void onItemSelected(AdapterView parent, View view, int pos,
                                   long id) {
            ((TextView) view).setTextColor(Color.RED);
        }
        public void onNothingSelected(AdapterView parent) {
        }
    
    });
    

    Android needs some major update or maybe dart and flutter should take over...

    Thanks Catluc

提交回复
热议问题