Checking if spinner is selected and having null value in Android

后端 未结 6 850
庸人自扰
庸人自扰 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条回答
  •  猫巷女王i
    2021-01-12 10:13

    you can define a spinner for departure and destination like you did there, then inside a button onClickListener you can check for the value before starting a new activity for example:

    if(spinner1.getSelectedItem.toString.equalIgnoreCase(value) && spinner2.getSelectedItem.toString.equalIgnoreCase(value)) {
        Intent mIntent = new Intent(MainActivity.this, DetailActivity.class) startActivity(mIntent); 
    }else{ 
        //Show Toast here
    

提交回复
热议问题