2

我有一个微调视图。我将其适配器设置为扩展基本适配器的 customAdapter。但是适配器的 get view 方法没有被调用。`

 public class CustomSpinnerAdapter extends BaseAdapter {
    private Context mContext;
    private LayoutInflater mInflater;

    private TextView mLine1, mLine2;

    private String mEmptyString = "--";

    public CustomSpinnerAdapter(Context context) {
        super();


        mContext = context;
        mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        // TODO Auto-generated constructor stub
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub

            return view;

    }}

然后我通过 setAdapter() 设置适配器。

4

2 回答 2

1

对于微调器,您需要实现 getDropDownView(),它是一种称为 DropDowns 的特殊方法...

于 2013-02-13T10:35:56.500 回答
0

您应该正确实现 getView() 函数:

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.your_single_spinner_row, null);
    }

    ... do whatever with the convertView (convertView.findViewById(...))...

    return convertView;

}
于 2013-02-13T10:35:28.757 回答