重写Spinner中ArrayAdapter的getView方法

保存代码,方便日后查看备忘。

        Spinner spinner = view.findViewById(R.id.floor_name);
        ArrayAdapter spadapter = new ArrayAdapter(
                CtrlActivity.this,android.R.layout.simple_spinner_item,floorDataList){
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                TextView tv = (TextView) super.getView(position, convertView, parent);
                tv.setTextColor(Color.parseColor("#000000"));
                tv.setTextSize(18);
                return tv;
            }
        };
        spadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(spadapter);
        spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView parent, View view, int position, long id) {

            }
            @Override
            public void onNothingSelected(AdapterView parent) { }
        });

 

你可能感兴趣的:(Android)