Android: two Spinner onItemSelected()

后端 未结 6 1076
死守一世寂寞
死守一世寂寞 2020-12-01 07:23

I have two spinners (day_spin and time_spin) in one Activity. I want to save the selected day_spin value into a variable. Is it possible to differenciate betwee

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-01 08:07

    try this...

    public void onItemSelected(AdapterView parent, View view, int pos, long id) {
    if(parent.getId() == R.id.spinnerone)
    {
           // operations            
    }
    else if(parent.getId() == R.id.spinnertwo)
    {
      //operations
    }
    }
    

提交回复
热议问题