2013-10-24 90 views
0

我正在使用Parse爲我的後端,並使用ParseQueryAdapter填充listview.根據他們的Android Guide,我應該重寫他們的getItemView方法來定製我的行項目。這裏的代碼getItemView沒有定義類型活動

public View getItemView(ParseObject object, View v, ViewGroup parent) { 
    super.getItemView(object, v, parent); 
    if (v == null) { 
    v = View.inflate(getContext(), R.layout.adapter_item, null); 
    } 


    TextView descriptionView = (TextView) v.findViewById(R.id.description); 
    descriptionView.setText(object.getString("description")); 
    return v; 
} 

返回的錯誤是:The method getItemView is not defined for the type Activity

回答

1

您應該擴展ParseQueryAdapter並有覆蓋getItemView不活動。 getItemView是ParseQueryAdapter的方法不是從活動

0

創建適配器類這樣

public class ParseAdapter extends ParseQueryAdapter<ParseObject> 
{ 
private Activity activity; 
public ParseAdapter(Activity act, 
     com.parse.ParseQueryAdapter.QueryFactory<ParseObject> queryFactory) { 
    super(act, queryFactory); 
    this.activity = act; 
    // setPaginationEnabled(false); 
    setObjectsPerPage(2); 
    setAutoload(true); 
} 



@Override 
public View getItemView(ParseObject object, View convertView,ViewGroup parent) { 
    final ViewHolder holder; 
    View vi = convertView; 
    if (vi == null) { 
     holder = new ViewHolder(); 
     inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
     vi = inflater.inflate(R.layout.cus_show_new, null, false); 

-------------- 

----------- 

------------- 
vi.setTag(holder); 
    } 

    else { 
     holder = (ViewHolder) vi.getTag(); 

    } 

return vi; 
} 
相關問題