My question is this: I'm doing a CRUD on Android and I have a problem on the UPDATE. As you can see, I want to collect all the data in a Bundle and then print them with setText () in the update form. The problem is that the last data, the displacement (which is commented because if it does not give me an error), I want to show it in a Spinner and I do not know what the method is.
This is how I send the data when I click on the items in the list:
listView_motocicletas.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int posicion, long id) {
Toast.makeText(Listado_motocicletas.this, listado_motocicletas.get(posicion), Toast.LENGTH_SHORT).show();
int clave= Integer.parseInt((listado_motocicletas.get(posicion).split(" ")[0]));
String marca= listado_motocicletas.get(posicion).split(" ")[1];
String matricula= listado_motocicletas.get(posicion).split(" ")[2];
String cilindrada= listado_motocicletas.get(posicion).split(" ")[3];
Intent intent = new Intent(Listado_motocicletas.this, Actualizar_moto.class);
intent.putExtra("id", clave);
intent.putExtra("marca", marca);
intent.putExtra("matricula", matricula);
intent.putExtra("cilindrada", cilindrada);
startActivity(intent);
}
});
}
And here is where I pick it up:
Bundle b= getIntent().getExtras();
if (b!=null){
id=b.getInt("id");
marca=b.getString("marca");
matricula=b.getString("matricula");
cilindrada=b.getString("cilindrada");
}
marca_actualizar=(EditText) findViewById(R.id.marca_actualizar);
matricula_actualizar=(EditText) findViewById(R.id.matricula_actualizar);
cilindrada_actualizar=(Spinner) findViewById(R.id.cilindrada_actualizar);
boton_actualizar=(Button)findViewById(R.id.boton_actualizar);
boton_eliminar=(Button) findViewById(R.id.boton_eliminar);
marca_actualizar.setText(marca);
matricula_actualizar.setText(matricula);
//cilindrada_actualizar.getSelectedItem();
The displacement I pick it up but I can not establish it because if not, I get an error.