새 항목을 목록에 추가 할 때 같은 위치에서 내 항목을 계속보고 싶습니다. 어떻게해야합니까?새 항목을 추가 할 때 내 목록보기 항목에 어떻게 보관할 수 있습니까?
나는 firebase를 사용하고 있지만 문제는 아닙니다. 내가 원하는 항목이 여기에
, 나는에서 내 항목을 추가
// 이런 식으로 날을 보내는 새로운 항목을 보려면 여기를
, MainClassif (o instanceof Post) {
posts.add((Post) o);
listaFeed.notifyDataSetChanged();
}
public class ListaFeed extends BaseAdapter {
private ArrayList<Post> posts;
private Context context;
public ListaFeed(ArrayList<Post> posts, Context context) {
this.posts = posts;
this.context = context;
}
@Override
public int getCount() {
return posts.size();
}
@Override
public Object getItem(int position) {
return posts.get(position-getCount()-1);
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
if (convertView==null){
convertView = LayoutInflater.from(this.context).inflate(R.layout.card_feed, null);}
Post post = (Post) getItem(position);
ImageView foto = convertView.findViewById(R.id.iv_foto);
TextView titulo = convertView.findViewById(R.id.tv_titulo);
TextView autor = convertView.findViewById(R.id.tv_autor);
TextView modo = convertView.findViewById(R.id.tv_modo);
Picasso.with(context).load(post.getFoto()).into(foto);
titulo.setText(post.getTitulo());
autor.setText(post.getAutor());
modo.setText(post.getModo());
return convertView;
}
}
arraylist의 0 번째 위치에 새 항목을 추가하면이 – Shruti