Pass parameter in onItemClick

Asked

Viewed 30 times

0

I’m having difficulty passing the parameter inside the repetition for in Android Studio. It lists the data coming from mysql, but I can’t pass the parameter to access the item.

for (int i=0; i<=ja.length(); i++){
            jo = ja.getJSONObject(i);
            numChamado[i] = jo.getString("numChamado");
            nomeCliente[i] = jo.getString("nomeCliente");
            logradouro[i] = jo.getString("logradouro");
            nome[i] = jo.getString("nome");
            processo[i] = jo.getString("processo");
            cidade[i] = jo.getString("cidade");


            lstData.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {


                    Intent intent = new Intent(getApplicationContext(), DescItem.class);
                    intent.putExtra("numChamado",numChamado[i]);
                    intent.putExtra("nomeCliente",nomeCliente[i]);
                    intent.putExtra("logradouro",logradouro[i]);
                    intent.putExtra("processo", processo[i]);
                    startActivity(intent);
                }
            });

        }

1 answer

0

I found out, it was easier than I thought! Just pass the [position] in place of [i]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.