Checking if spinner is selected and having null value in Android

后端 未结 6 849
庸人自扰
庸人自扰 2021-01-12 09:27

I want to check first if spinner has null values based on the following:

String Name= spinnerName.getSelectedItem().toString();
if(Name != null) {     
} els         


        
6条回答
  •  梦谈多话
    2021-01-12 10:19

    first you have to check either any item in the spinner selected or not and initialized or not

    if (modeOfReportingSpinner.getSelectedItem()!=null){
            modeOfString = modeOfReportingSpinner.getSelectedItem().toString();
        }
    

提交回复
热议问题