选中后,禁用旋转器中的项目

时间:2016-11-25 00:06:22

标签: java android mysql android-spinner

我从MySQL填充spinner数据 [表1,表2,表3 .....等等]但是现在我想要当我选择任何位置或表时它将从微调器列表中禁用

adapter= new ArrayAdapter<String>(this, R.layout.spinner_item_layout,R.id.txt,listItems);
        sp.setAdapter(adapter);



     sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
         @Override
         public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            String SelectedItem=sp.getItemAtPosition(position).toString();

           // String SelectedItem=sp.getSelectedItem().toString();
             if(id==0){

             }else {
                 Intent intent = new Intent();
                 intent.putExtra("spinnerData", SelectedItem);
                 intent.setClass(MainActivity.this, SecondActivity.class);
                 startActivity(intent);


             }

         }

0 个答案:

没有答案