写android级联spinner时,报错。
PHPz
PHPz 2017-04-17 17:28:46
0
2
798

写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);
        }
    });
PHPz
PHPz

学习是最好的投资!

reply all(2)
巴扎黑
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");
        }
    });
    
    希望对你有用
PHPzhong

It’s okay to use setOnItemSelectedListener

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!