I'm pulling data and loading it into a BaseAdapter for my List View. Currently, the items in the listview are the same as the last item added, so the list looks like this:
Item 3
Item 3
Item 3
Instead of:
Item 1
Item 2
Item 3
I've checked over the data sources, and the data that's loaded from the source is unique each time. I think there's somehting wrong with my BaseAdapter, but I'm not sure what it is. Here's my BaseAdapter:
BaseAdapter.java
ArrayList<ThreadListData> myList = new ArrayList<>();
LayoutInflater inflater;
Context context;
public ThreadBaseAdapter(Context context, ArrayList<ThreadListData> myList) {
this.context = context;
inflater = LayoutInflater.from(this.context);
this.myList = myList;
}
@Override
public int getCount() {
return myList.size();
}
@Override
public ThreadListData getItem(int position) {
return myList.get(position);
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = LayoutInflater.from(this.context);
convertView = inflater.inflate(R.layout.listitem_newthread, parent, false);
}
ThreadListData listData = getItem(position);
TextView name = (TextView)convertView.findViewById(R.id.name_newthread);
TextView username = (TextView)convertView.findViewById(R.id.username_newthread);
name.setText(listData.getName());
username.setText(listData.getName());
ParseImageView profile = (ParseImageView)convertView.findViewById(R.id.profilepicture);
BitmapTask task = new BitmapTask(listData.getImage());
task.execute(profile);
return convertView;
}
I'll start with my BaseAdapter, and can show more code if requested. All Help Is Appreciated!
You missed to return the
position
Modifiy your
getItemId
as