0

我在后端使用 Parse 并使用 ParseQueryAdapter 填充列表视图。根据他们的Android 指南,我应该覆盖他们的 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

4

3 回答 3

1

您应该扩展 ParseQueryAdapter 并在那里覆盖不在活动中的 getItemView。getItemView 是 ParseQueryAdapter 中的一种方法,而不是 Activity 中的方法

于 2013-10-24T10:04:33.343 回答
0

根据这个 Parse 教程,https: //parse.com/tutorials/parse-query-adapter,你应该继承 ParseQueryAdapter。

于 2014-04-13T15:15:11.650 回答
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;
}
于 2013-11-04T12:17:47.817 回答