奇怪的Recycler视图绑定持有者抛出空指针异常

时间:2014-12-27 16:51:06

标签: android adapter android-5.0-lollipop android-recyclerview

我在我的应用程序中成功实现了回收站视图,但现在我注意到它会抛出这个Nullpointer异常,下面是崩溃日志

java.lang.NullPointerException
at com.example.project.CustomRecyclerAdapter.onBindViewHolder(CustomRecyclerAdapter.java:83)
at com.example.project.CustomRecyclerAdapter.onBindViewHolder(CustomRecyclerAdapter.java:26)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:4048)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3366)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3258)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1803)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1302)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1265)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:522)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:1918)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:2155)
at android.view.View.layout(View.java:14061)
at android.view.ViewGroup.layout(ViewGroup.java:4374)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
at android.view.View.layout(View.java:14061)
at android.view.ViewGroup.layout(ViewGroup.java:4374)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14061)
at android.view.ViewGroup.layout(ViewGroup.java:4374)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14061)
at android.view.ViewGroup.layout(ViewGroup.java:4374)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14061)
at android.view.ViewGroup.layout(ViewGroup.java:4374)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1986)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1807)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4454)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4895)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
at dalvik.system.NativeStart.main(Native Method)

CustomRecyclerAdapter第83行

viewHolder.textView.setText(getTitle(position));

CustomRecyclerAdapter第26行

private final int orientation;

你们有什么想法我能得到这个吗?

查看持有人

public static class ViewHolder extends RecyclerView.ViewHolder {

   public ImageView imageView;
   public TextView time;
   public TextView textView;
   public TextView temperature;

   public ViewHolder(View row){
       super(row);
       imageView = (ImageView) row.findViewById(R.id.imageView);
       time = (TextView) row.findViewById(R.id.time);
       textView = (TextView) row.findViewById(R.id.textView);
       temperature = (TextView) row.findViewById(R.id.temperature);
   }
}

0 个答案:

没有答案