2013-02-13 120 views
2

我有一個微調視圖。我將它的適配器設置爲擴展基本適配器的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

回答

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; 

} 
1

對於需要實現getDropDownView()紡紗廠,它是一個呼籲DROPDOWNS speciall方法...

相關問題