Android ParseFile.getUrl()';关于空对象引用
我正在调用parse cloud中的图像,并使用毕加索将它们加载到我的gridview支架中 这是doInbackGroundAndroid ParseFile.getUrl()';关于空对象引用,android,parse-platform,Android,Parse Platform,我正在调用parse cloud中的图像,并使用毕加索将它们加载到我的gridview支架中 这是doInbackGround @Override protected Void doInBackground(Void... Params) { feedsarraylist = new ArrayList<ParseFeeds>(); try { ParseQuery<ParseObject&
@Override
protected Void doInBackground(Void... Params) {
feedsarraylist = new ArrayList<ParseFeeds>();
try {
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("AroundMe");
query.orderByDescending("createdAt");
//query.whereWithinKilometers()
ob = query.find();
for (ParseObject feeds : ob) {
ParseFile thumb = (ParseFile) feeds.get("videoThumbs");
//ParseFile video = (ParseFile) feeds.get("file");
ParseFeeds map = new ParseFeeds();
//map.setImage(thumb.getUrl());
//Uri videoUri = Uri.parse(video.getUrl());
map.setImage(thumb.getUrl());
feedsarraylist.add(map);
}
} catch (ParseException e) {
Log.e("ParseException", "parse: " + e);
}
return null;
}
这是我将其加载到GridViewAdapter.class的地方
Picasso.with(context).load(feedsarraylist.get(position).getImage()).into(holder.ThumbView);
Logcat详细信息
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.parse.ParseFile.getUrl()' on a null object reference
at com.teamtreehouse.ribbit.FeedsFragment$RemoteDataTask.doInBackground(FeedsFragment.java:67)
at com.teamtreehouse.ribbit.FeedsFragment$RemoteDataTask.doInBackground(FeedsFragment.java:45)
我只是在这里猜测,因为您没有指定错误发生的位置
ParseFile thumb = (ParseFile) feeds.get("videoThumbs");
map.setImage(thumb.getUrl())
如果
feeds
没有videoThumbs
元素,thumb
将为null
,因此您会出错。检查提要元素的内容。我在这里只是猜测,因为您没有指定错误发生的位置
ParseFile thumb = (ParseFile) feeds.get("videoThumbs");
map.setImage(thumb.getUrl())
如果feeds
没有videoThumbs
元素,thumb
将为null
,因此您会出错。检查您的提要
元素的内容。我在解析类中有videoThumbs列。您对此有什么解决方案吗?@Savita您最好确保您的解析文件
包含videoThumbs
。记录并找出设置videoThumbs
失败的位置。可能是在你得到它之后设置的。只需调试你的代码并检查提要的值。@RvdK我已经添加了logcat。videoThumbs列确实存在于我的解析类中。我在解析类中有videoThumbs列。您对此有什么解决方案吗?@Savita您最好确保您的ParseFile
包含videoThumbs
。记录并找出设置videoThumbs
失败的位置。可能是在你得到它之后设置的。只需调试你的代码并检查提要的值。@RvdK我已经添加了logcat。videoThumbs列不存在于我的解析类中