How can I change this code so that it adds every new object to the top of the list instead of the bottom? I would like the last object to be added to the very top of the list, so you see older objects when you scroll the bottom of the list.
public class StatusAdapter extends ArrayAdapter {
protected Context mContext;
protected List<ParseObject> mStatus;
public StatusAdapter(Context context, List<ParseObject> status) {
super(context, R.layout.homepage, status);
mContext = context;
mStatus = status;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(
R.layout.homepage, null);
holder = new ViewHolder();
holder.usernameHomepage = (TextView) convertView
.findViewById(R.id.usernameHP);
holder.statusHomepage = (TextView) convertView
.findViewById(R.id.statusHP);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
ParseObject statusObject = (ParseObject)mStatus.get(position);
String username = statusObject.getString("newUser") + ":";
holder.usernameHomepage.setText(username);
String status = statusObject.getString("newStatus");
holder.statusHomepage.setText(status);
return convertView;
}
public static class ViewHolder {
TextView usernameHomepage;
TextView statusHomepage;
}
}
source
share