I want to make that by selecting an item of SeleccionClienteActivity
go to RegistroPedidoActivity
, capturing the phone data, the method setOnItemClickListener
does not work, does not even lead to the next activity.
I do not know where the problem is.
This is my code:
public class SeleccionClienteActivity extends AppCompatActivity {
private ListView listaCliente;
private List<Cliente> clientes;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_seleccion_cliente);
listaCliente = findViewById(R.id.lvClienteList);
ClienteService clienteService = APICliente.getClient().create(ClienteService.class);
listaCliente.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
ArrayList<Cliente> milistaCliente = new ArrayList<Cliente>();
try {
JSONArray array = new JSONArray(milistaCliente);
JSONObject objeto = array.getJSONObject(position);
int telefonoCli = objeto.getInt("telef_cli");
Intent intent = new Intent(SeleccionClienteActivity.this, RegistroPedidoActivity.class);
intent.putExtra("telefonoCli",telefonoCli);
startActivity(intent);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
Call call = clienteService.findAll();
call.enqueue(new Callback() {
@Override
public void onResponse(Call call, Response response) {
clientes = (List<Cliente>) response.body();
listaCliente.setAdapter(new
ClienteListAdapter(getApplicationContext(), clientes));
}
@Override
public void onFailure(Call call, Throwable t) {
Toast.makeText(getApplicationContext(), "Falló",
Toast.LENGTH_SHORT).show();
}
});
}
}
I hope you can help me.
Thank you.