我在MainActivity中使用了三个片段。
它来自fata例外:主要。说, RequestFragment.class第54行是异常的原因:
adapter = new RequestAdapter(getListView().getContext(), mRequests);
RequestAdapter 是一个分开实现的类。
谢谢! 的代码:
@Override
public void onResume() {
super.onResume();
getActivity().setProgressBarIndeterminateVisibility(true);
currentUserName = ParseUser.getCurrentUser().getUsername();
getActivity().setProgressBarIndeterminate(true);
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>(ParseConstants.CLASS_ACTIVITYREQUEST);
query.whereEqualTo(ParseConstants.KEY_RECIPIENTNAME, currentUserName);
//Reorder the result according to the time users shake the phone
query.addDescendingOrder(ParseConstants.KEY_CREATEDAT);
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> requests, ParseException e) {
getActivity().setProgressBarIndeterminateVisibility(false);
if(e == null){
mRequests = requests;
adapter = new RequestAdapter(getListView().getContext(), mRequests);
setListAdapter(adapter);
}
else{
Log.d(TAG, "no request");
}
}
});
}
答案 0 :(得分:0)
你必须在这里改变
adapter = new RequestAdapter(getListView().getContext(), mRequests);
到
adapter = new RequestAdapter(getActivity(), mRequests);