这是我在FeedActivity中初始化适配器的方法:
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setHasFixedSize(true);
FeedAdapter adapter = new FeedAdapter(FeedActivity.this, retrieveYeets());
recyclerView.setAdapter(adapter);
这是我的错误:
java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
at com.yitter.feed.FeedAdapter.getItemCount(FeedAdapter.java:478)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:3170)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3067)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3518)
at android.view.View.layout(View.java:16636)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:598)
at android.view.View.layout(View.java:16636)
at android.view.ViewGroup.layout(ViewGroup.java:5437)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:107
我在FeedAdapter中抱怨以下代码:
@Override
public int getItemCount() {
return mYeets.size();
}
我不知道为什么我的清单是空的。显然,我的列表中有一个NullPointerException,但它并不明显。它可能与列表中元素的位置有关。有人有建议吗?
答案 0 :(得分:1)
我认为问题出在这里
public FeedAdapter(Context context, List<ParseObject> yeets) {
super();
this.mYeets = yeets;
this.mContext = context;
this.adapter = this;
profilePictureImageLoader = new ImageLoader(new ProfilePictureFileCache(mContext));
}
你忘了追加&#39;这个&#39;在beginnig中
security:
firewalls:
default:
anonymous: ~
http_basic: ~
provider: our_db_provider
logout:
path: /logout
providers:
our_db_provider:
entity:
class: CmsUserBundle:User
property: username
encoders:
Cms\UserBundle\Entity\User: plaintext