recherche

Maison  >  Questions et réponses  >  le corps du texte

写android级联spinner时,报错。

写android级联时,报错。
Caused by: java.lang.RuntimeException: setOnItemClickListener cannot be used with a spinner.oid

代码如下:
sp_college.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            arrayAdapter=new ArrayAdapter<CharSequence>(MainActivity.this,android.R.layout.simple_spinner_item,college[i]);
            sp_college.setAdapter(arrayAdapter);
        }
    });
PHPzPHPz2772 Il y a quelques jours806

répondre à tous(2)je répondrai

  • 巴扎黑

    巴扎黑2017-04-17 17:30:46

    spinnerView.setOnItemSelectedListener(
    
        new OnItemSelectedListener() {
            public void onItemSelected(AdapterView<?> parent, 
                View view, int position, long id) {
                showToast("Spinner1: position="   position   " id="   id);
            }
        
            public void onNothingSelected(AdapterView<?> parent) {
                showToast("Spinner1: unselected");
            }
        });
        
        希望对你有用

    répondre
    0
  • PHPz

    PHPz2017-04-17 17:30:46

    setOnItemSelectedListener可以吧

    répondre
    0
  • Annulerrépondre