我有一个微调视图。我将其适配器设置为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()设置适配器。
答案 0 :(得分:1)
对于微调器,你需要实现getDropDownView(),这是一个名为DropDowns的特殊方法......
答案 1 :(得分: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;
}