baseAdapter的getView方法没有被调用

问题描述:

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

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

告诉我们你是怎么设置你的适配器 – 2013-02-13 10:35:17

你应该实现正确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; 

} 

对于需要实现getDropDownView()纺纱厂,它是一个呼吁DROPDOWNS speciall方法...