-1

下面是我的 ArrayAdapter,我想放大视图以适应我对下拉微调器的需要。

    ArrayAdapter<String> arrShirtType = new ArrayAdapter<String>
        (this, android.R.layout.simple_spinner_item,shirtType)
        {
            private LayoutInflater inflater = LayoutInflater.from(getBaseContext());
            public View getView(int position, View convertView,ViewGroup parent) 
                {
                    View vi = convertView;
                    vi = inflater.inflate(R.layout.spinner_view_style, parent);
                    TextView txt = (TextView)findViewById(R.id.spinner_textview);
                    ((TextView) vi).setTypeface(font1);
                    ((TextView) vi).setTextSize(65);
                    return vi;
                }
            public View getDropDownView(int position, View convertView,ViewGroup parent) 
                {   
                    View vi = convertView;
                    vi = inflater.inflate(R.layout.spinner_view_style, parent);
                    TextView txt = (TextView)findViewById(R.id.spinner_textview);
                    ((TextView) vi).setTypeface(font1);
                    ((TextView) vi).setTextSize(65);
                    return vi;
                }
        };

问题更新

我将视图膨胀到 ArrayAdapter 的方式是否正确?以下是错误日志

11-06 21:03:47.307: E/AndroidRuntime(1356): FATAL EXCEPTION: main
11-06 21:03:47.307: E/AndroidRuntime(1356): java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
11-06 21:03:47.307: E/AndroidRuntime(1356):     at android.widget.AdapterView.addView(AdapterView.java:477)
11-06 21:03:47.307: E/AndroidRuntime(1356):     at android.view.LayoutInflater.inflate(LayoutInflater.java:497)
11-06 21:03:47.307: E/AndroidRuntime(1356):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-06 21:03:47.307: E/AndroidRuntime(1356):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-06 21:03:47.307: E/AndroidRuntime(1356):     at com.job.mommy.Shirt$1.getView(Shirt.java:90)
11-06 21:03:47.307: E/AndroidRuntime(1356):     
4

1 回答 1

2

您必须初始化充气机。例如:

inflater = LayoutInflater.from(context);
于 2012-11-06T14:00:32.840 回答