Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Self-Destructing Message Android App Retrieving and Viewing Messages Creating a Custom List Adapter for Messages

babono nurul akbar
babono nurul akbar
5,731 Points

username doesn't show on list, only icon

Hi, i'm stuck since i think i already got my code same as ben's, and it just occurred when I added the custom icon, the previous stage it's fine.

here is my InboxFragment.java, i think the problem is in here, but until now i can't find it what's wrong with my code. any help will be appreciated.

<code> public class InboxFragment extends ListFragment{

protected List<ParseObject> mMessages;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_inbox, container, false);
    return rootView;

public void onResume() {


    ParseQuery<ParseObject> query = new ParseQuery<ParseObject>(ParseConstants.CLASS_MESSAGES);
    query.whereEqualTo(ParseConstants.KEY_RECIPIENT_IDS, ParseUser.getCurrentUser().getObjectId());
    query.findInBackground(new FindCallback<ParseObject>() {
        public void done(List<ParseObject> messages, ParseException e) {

            if(e == null){
                //  We found messages!
                mMessages = messages;

                String[] usernames = new String[mMessages.size()];
                int i = 0;
                for(ParseObject message : mMessages){
                    usernames[i] = message.getString(ParseConstants.KEY_SENDER_NAME);
                MessageAdapter adapter = new MessageAdapter(


} </code>

and this is my MessageAdapter.java public class MessageAdapter extends ArrayAdapter<ParseObject>{

protected Context mContext;
protected List<ParseObject> mMessages;
private static final String TAG = "MessageActivity";

public MessageAdapter(Context context, List<ParseObject>messages){
    super(context, R.layout.message_item, messages);
    mContext = context;
    mMessages = messages;

public View getView(int position, View convertView, ViewGroup parent){
    ViewHolder holder;

    if (convertView == null) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.message_item, null);
        holder = new ViewHolder();
        holder.iconImageView = (ImageView)convertView.findViewById(R.id.messageIcon);
        holder.nameLabel = (TextView)convertView.findViewById(R.id.senderLabel);
        holder = (ViewHolder)convertView.getTag();

    ParseObject message = mMessages.get(position);

    if (message.getString(ParseConstants.KEY_FILE_TYPE).equals(ParseConstants.TYPE_IMAGE)) {


    return convertView;
private static class ViewHolder {
    ImageView iconImageView;
    TextView nameLabel;


sorry for my bad english btw

1 Answer

Hi Nurul,

I think I've spotted your problem. It looks like there's a simple syntax error on the line where you set the holder.nameLabel text (Hint: look for holder.nameLabel.setText() in the getView() method) in you MessageAdapter file. Their are one too many message.getString() calls.

Good luck!

babono nurul akbar
babono nurul akbar
5,731 Points

wow thank you very much! you're my saviour