joy
- Forum posts: 1
Apr 21, 2016, 1:51:26 PM via Website
Apr 21, 2016 1:51:26 PM via Website
Listview Size is 10 items. Till it does not display anything in Listview.I am adding List of Item in above adapter but not able to get the Listview single row. Please help me to solve my error adapter.
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import java.util.List;
import bughunters.tashfik.chooseapp.Model.Category;
import bughunters.tashfik.chooseapp.Model.Comment;
import bughunters.tashfik.chooseapp.R;
public class CommentViewAdapter extends BaseAdapter {
private Context context;
private List<Comment> messagesItems;
// public static List<String> imagelist;
public CommentViewAdapter(Context context, List<Comment> navDrawerItems) {
Toast.makeText(context,"Sixe ids"+String.valueOf(navDrawerItems.size()),Toast.LENGTH_LONG).show();
this.context = context;
this.messagesItems = navDrawerItems;
}
@Override
public int getCount() {
return messagesItems.size();
}
@Override
public Object getItem(int position) {
return messagesItems.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.comments_list_item, null);
TextView textViewProfileName = (TextView) convertView.findViewById(R.id.textViewProfileName);
TextView textViewMesssage = (TextView) convertView.findViewById(R.id.textViewMesssage);
TextView textViewTime = (TextView) convertView.findViewById(R.id.textViewTime);
Toast.makeText(context,messagesItems.get(position).getUsername(),Toast.LENGTH_LONG).show();
ImageView imageViewUserProfilePic = (ImageView) convertView.findViewById(R.id.imageViewUserProfilePic);
textViewProfileName.setText(messagesItems.get(position).getUsername());
textViewMesssage.setText(messagesItems.get(position).getMessage());
textViewTime.setText(messagesItems.get(position).getTime());
return convertView;
}
}
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.