0

Im working with firebaseListAdapter, here I query data and it shows the new results at the bottom of my listview. what I did to bring this values to the top is as below:

@Override
            public Usuarios getItem(int position) {
                return super.getItem(getCount()-1-position);
            }

and this is my onClick on the items

 //((TextView)v.findViewById(android.R.id.text1)).setText(model.getEmail());
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
        mDatabase = mAdapter.getRef(position);
        Toast.makeText(MainActivity.this, ""+mDatabase.getKey(), Toast.LENGTH_SHORT).show();
        Intent intent = new Intent(MainActivity.this, UserEdit.class);
        intent.putExtra("uid",mDatabase.getKey());
        intent.putExtra("Nombre", mAdapter.getItem(position).getNombre());
        intent.putExtra("Email", mAdapter.getItem(position).getEmail());
        intent.putExtra("Cars", mAdapter.getItem(position).getCars());
        intent.putExtra("Planes", mAdapter.getItem(position).getPlanes());
        intent.putExtra("Bus", mAdapter.getItem(position).getBus());
        startActivity(intent);
    }
});

this works and now I can see the values placed at the bottom in the top but the thing is the position of the items are not same. How do I fix this ?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Gastón Saillén
  • 12,319
  • 5
  • 67
  • 77

1 Answers1

1

I just solved my problem doing this

 mDatabase = mAdapter.getRef(getCount()-1-position);

i forgot to change the position of my Adapter, so i was changing the listview position but not the position from where to get the items in my Adapter

Gastón Saillén
  • 12,319
  • 5
  • 67
  • 77