{"action":"opened","issue":{"url":"https://api.github.com/repos/googlesamples/android-RecyclerView/issues/15","repository_url":"https://api.github.com/repos/googlesamples/android-RecyclerView","labels_url":"https://api.github.com/repos/googlesamples/android-RecyclerView/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/googlesamples/android-RecyclerView/issues/15/comments","events_url":"https://api.github.com/repos/googlesamples/android-RecyclerView/issues/15/events","html_url":"https://github.com/googlesamples/android-RecyclerView/issues/15","id":156554810,"number":15,"title":"RecyclerView Causing NullPointer on CardView Item","user":{"login":"troy21688","id":16483832,"avatar_url":"https://avatars.githubusercontent.com/u/16483832?v=3","gravatar_id":"","url":"https://api.github.com/users/troy21688","html_url":"https://github.com/troy21688","followers_url":"https://api.github.com/users/troy21688/followers","following_url":"https://api.github.com/users/troy21688/following{/other_user}","gists_url":"https://api.github.com/users/troy21688/gists{/gist_id}","starred_url":"https://api.github.com/users/troy21688/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/troy21688/subscriptions","organizations_url":"https://api.github.com/users/troy21688/orgs","repos_url":"https://api.github.com/users/troy21688/repos","events_url":"https://api.github.com/users/troy21688/events{/privacy}","received_events_url":"https://api.github.com/users/troy21688/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-24T16:41:01Z","updated_at":"2016-05-24T16:41:01Z","closed_at":null,"body":"I am using a RecylerView to populate CardView items. I am noticing that the RecyclerView is generating a NullPointer here, as for some reason the RecyclerView references the parent view and not the individual CardView.\r\n\r\nI believe the error is occurring here:\r\n\r\n      public ViewHolder(View v) {\r\n                super(v);\r\n                userAvatar = (ImageView) findViewById(R.id.profile_image);\r\n                userID = (TextView) findViewById(R.id.user_ID);\r\n                userComment = (TextView) findViewById(R.id.user_comment_textview);\r\n            }\r\n\r\nHere is my individual CardView XML (individual_comment.xml):\r\n\r\n    <android.support.v7.widget.CardView xmlns:android=\"http://schemas.android.com/apk/res/android\"\r\n    xmlns:app=\"http://schemas.android.com/tools\"\r\n    xmlns:card_view=\"http://schemas.android.com/apk/res-auto\"\r\n    android:id=\"@+id/card_view\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"wrap_content\"\r\n    android:layout_margin=\"5dp\"\r\n    card_view:cardCornerRadius=\"4dp\">\r\n\r\n\r\n    <LinearLayout\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:background=\"@color/comment_backgroud_grey\"\r\n        android:orientation=\"horizontal\"\r\n        android:padding=\"@dimen/individual_comment_padding\">\r\n\r\n        <de.hdodenhof.circleimageview.CircleImageView\r\n            android:id=\"@+id/profile_image\"\r\n            android:layout_width=\"@dimen/avatar_image_dimension\"\r\n            android:layout_height=\"@dimen/avatar_image_dimension\"\r\n            android:layout_gravity=\"center_vertical\"\r\n            android:layout_marginLeft=\"8dp\"\r\n            android:layout_marginStart=\"8dp\"\r\n            android:src=\"@drawable/empty_avatar_256x256\"\r\n            app:civ_border_color=\"#FF000000\"\r\n            app:civ_border_width=\"@dimen/circle_image_border_width\" />\r\n\r\n        <LinearLayout\r\n            android:layout_width=\"match_parent\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:orientation=\"vertical\">\r\n\r\n            <TextView\r\n                android:id=\"@+id/user_ID\"\r\n                android:layout_width=\"wrap_content\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:layout_marginEnd=\"16dp\"\r\n                android:layout_marginLeft=\"8dp\"\r\n                android:layout_marginRight=\"16dp\"\r\n                android:layout_marginStart=\"8dp\"\r\n                android:layout_marginTop=\"8dp\"\r\n                android:text=\"Name\"\r\n                android:textColor=\"@color/black\"\r\n                android:textSize=\"@dimen/individual_comment_userID_textsize\"\r\n                android:textStyle=\"bold\" />\r\n\r\n            <TextView\r\n                android:id=\"@+id/user_comment_textview\"\r\n                android:layout_width=\"wrap_content\"\r\n                android:layout_height=\"wrap_content\"\r\n                android:layout_marginEnd=\"16dp\"\r\n                android:layout_marginLeft=\"8dp\"\r\n                android:layout_marginRight=\"16dp\"\r\n                android:layout_marginStart=\"8dp\"\r\n                android:hint=\"This text should be the comment that I Type, not the default text I set in the XML.\"\r\n                android:paddingBottom=\"1dp\"\r\n                android:textColor=\"@color/black\"\r\n                android:textSize=\"@dimen/individual_comment_userComment_textsize\" />\r\n\r\n        </LinearLayout>\r\n    </LinearLayout>\r\n</android.support.v7.widget.CardView>\r\n\r\nI am receiving a NullPointer for this line:\r\n\r\n     @Override\r\n            public void onBindViewHolder(ViewHolder holder, int position) {\r\n    //nullponter, I believe it is not recognizing \"user Comment\"                holder.userComment.setText(mDataSet.get(position).getUserComment());\r\n                    String x = mDataSet.get(position).getUserComment();\r\n                    Log.v(\"ON_BIND_VIEW\", \"THE STRING IS \" + x);\r\n                    Log.v(\"THE_POSITION\", \"THE POSITION IS \" + position);\r\n                }\r\n\r\nonCreateViewHolder:\r\n      \r\n\r\n      @Override\r\n        public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,\r\n                                                       int viewType) {\r\n            // create a new view\r\n            View v = LayoutInflater.from(parent.getContext())\r\n                    .inflate(R.layout.individual_comment, parent, false);\r\n            // set the view's size, margins, paddings and layout parameters\r\n            return new ViewHolder(v);\r\n        }"}}
{"actor":{"display_login":"troy21688"}}