Jairo Filho
Jairo Filho

Reputation: 342

Get value other than position from listview

I have this piece of code:

    ListView lista = (ListView)findViewById(android.R.id.list);
    lista.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            arquivo = Retorno.retArquivo.get(position);
            Intent trocatela = new Intent(Popular.this,Detalhe.class);
            Popular.this.startActivity(trocatela);
            Popular.this.finish();
        }
    });

I can mount the listview from an arraylist, and move to another activity, all works ok, but I need to get a value that's in the list.

EDIT:

Other value than position.

EDIT2:

I set the values here:

    private List<Resultados> populateSampleApplication() {

        List<Resultados> list = new ArrayList<Resultados>();

        int total = Retorno.retArquivo.size();

        for (int i = 0; i < total; i++) {
            if (Retorno.retTipo.get(i).equals(Login.tipo)) {
                Resultados ap = new Resultados();
                ap.setNome(Retorno.retNome.get(i));
                ap.setArquivo(Retorno.retArquivo.get(i));
                ap.setDados(Retorno.retDados.get(i));
                ap.setExibido(Retorno.retExibido.get(i));
                ap.setReconhecido(Retorno.retReconhecido.get(i));
                list.add(ap);
            }
        }

        return list;
    }

And need to get this back: ap.setArquivo(Retorno.retArquivo.get(i));

Upvotes: 1

Views: 728

Answers (2)

Jairo Filho
Jairo Filho

Reputation: 342

Thanks for the help. This worked:

String tx2 = ((TextView)view.findViewById(R.id.arquivo)).getText().toString();

Upvotes: 0

tyczj
tyczj

Reputation: 73753

you can take your adapter that you used to create the listview and get the data at the position

Resultados ap = (Resultados)adapter.getItem(position);

and you have the data at that position

Upvotes: 2

Related Questions