Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Jie Ding
4,839 PointsWhy my Ribbit could not be launched after adding the custom MessageAdapter?
My code is exactly the same as in the lecture of "Creating a custom list adapter for messages", but it goes to error. From the logcat, the error comes from the NullPointerException from the getView() method in the MessageAdapter class. I still do not know why. Can anyone help me? I really appreciate your help!
1 Answer

Jie Ding
4,839 PointsOK I have solved the issue. I modified the getView() methods provided in the lecture to the following code. Hope it will help someone with similar problems.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = convertView;
if (rowView == null) {
rowView = LayoutInflater.from(mContext).inflate(R.layout.message_item, null);
ViewHolder viewHolder = new ViewHolder();
viewHolder.iconImageView = (ImageView) rowView.findViewById(R.id.message_icon);
viewHolder.nameLabel = (TextView) rowView.findViewById(R.id.sender_label);
rowView.setTag(viewHolder);
}
ViewHolder holder = (ViewHolder) rowView.getTag();
ParseObject message = mMessages.get(position);
if (message.getString(ParseConstants.KEY_FILE_TYPE).equals(ParseConstants.TYPE_IMAGE)) {
holder.iconImageView.setImageResource(R.drawable.ic_action_picture);
}
else {
holder.iconImageView.setImageResource(R.drawable.ic_action_play_over_video);
}
holder.nameLabel.setText(message.getString(ParseConstants.KEY_SENDER_NAME));
return rowView;
}