2011-11-02 73 views
0

我嘗試將ArrayAdapter的實現與Activity類分開。 到目前爲止,我把它移動到單獨的類,但getSystemService()導致我的問題。Android自己的ArrayAdapter實現

I`ve嘗試在構造函數傳遞上下文這樣

public KontaktAdapter(Context context, int textViewResourceId, ArrayList<Kontakt> items) { 
      super(context, textViewResourceId, items); 
      this.context = context; 

但沒有下面的工作

LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 

編輯:最後這似乎爲我工作現在

LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 

回答

0

試試

LayoutInflater vi = LayoutInflater.from(context);