在我的调试器中,我的自定义查询是在没有崩溃的情况下创建的。但是,从不调用getItemView,我不知道为什么:
public class CustAdapter extends ParseQueryAdapter {
public CustAdapter(Context context) {
super(context, new ParseQueryAdapter.QueryFactory<MyData>() {
public ParseQuery create() {
ParseQuery custQuery = new ParseQuery("MyData");
ParseUser currentUser = ParseUser.getCurrentUser();
String selectedOption = MainActivity.getSelectedOption();
custQuery.whereEqualTo("option",
selectedOption).whereExists("bookTitle");
questionsQuery.orderByDescending("createdAt");
return custQuery;
} // end create()
}); // end anon inner class and end super call
}
public static class ViewHolder {
TextView titleTV;
TextView detailsTV;
}
@Override
public View getItemView(ParseObject object, View v, ViewGroup parent) {
ViewHolder holder;
if (v == null) {
v = View.inflate(getContext(), R.layout.book_item, null);
super.getItemView(object, v, parent);
holder = new ViewHolder();
holder.titleTV = (TextView)v.findViewById(R.id.bTitle);
holder.detailsTV = (TextView)v.findViewById(R.id.bDetails);
v.setTag(holder);
}
else
holder = (ViewHolder)v.getTag();
holder.titleTV.setText(object.getString("bookTitle"));
holder.detailsTV.setText(object.getString("bookDetails"));
return v;
}
}
在我的片段中我做:CustAdapter adapter = new CustAdapter(getActivity()); lv.setAdapter(适配器)。
答案 0 :(得分:1)
代码是正确的,问题是将listview设置为在xml中不可见。使其在控制器中可见,显示云结果。令人惊讶的是,android studio仍然没有达到getItemView中if语句设置的断点!