我想在我的列表中添加一些基於當前用戶的用戶名的特定ParseObject。但這個代碼只結束了在NullPointerException異常上線:如何指定要添加到列表中的parseObject <parseObject>
query.findInBackground(新FindCallback()
mStatus.add(status.get(I));
有人請幫我解決這個問題。謝謝。
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = null;
view = inflater.inflate(R.layout.update_status, container, false);
ParseUser currentUser = ParseUser.getCurrentUser();
final String strCurrentUsername = currentUser.getUsername();
if (currentUser != null) {
//try
final ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Status");
query.orderByDescending("createdAt");
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(final List<ParseObject> status, ParseException e) {
if(e == null){
//success
for(int i = 0; i <status.size();i++){
String usernow = status.get(i).getString("user");
if(usernow.equals(strCurrentUsername)){
Toast.makeText(getActivity(), "num"+i, Toast.LENGTH_SHORT).show();
mStatus.add(status.get(i));
}
else i++;
}
//mStatus = status;
StatusAdapter statusAdapter = new StatusAdapter(getListView().getContext(), mStatus);
setListAdapter(statusAdapter);
}else{
//there was a problem
}
}
});
} else {
Intent intent = new Intent(getActivity(), FirstActivity.class);
startActivity(intent);
}
return view;
}
是mStatus initalized? –