Badblog

welcome to our blog

We are Learncodz.


Posts

Comments

The Team

Blog Codz Author

Connect With Us

Join To Connect With Us

Portfolio

    Posted by: Unknown Posted date: 16:43 / comment : 0

    package com.teamtreehouse.ribbit;

    import java.util.List;

    import android.content.Context;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ArrayAdapter;
    import android.widget.ImageView;
    import android.widget.TextView;

    import com.parse.ParseObject;

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

        @Override
        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);
                convertView.setTag(holder);
            }
            else {
                holder = (ViewHolder)convertView.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 convertView;
        }
       
        private static class ViewHolder {
            ImageView iconImageView;
            TextView nameLabel;
        }
       
        public void refill(List<ParseObject> messages) {
            mMessages.clear();
            mMessages.addAll(messages);
            notifyDataSetChanged();
        }
    }






    icon allbkg

    Tagged with:

    Next
    Newer Post
    Previous
    Older Post

    No comments:

Comments

The Visitors says
Download Free Software Latest Version