2
I am developing a service scheduling system and in a Listview I can take a customer’s data and move to a Query Activity. I created an editing menu and would like to pass this same data to the new Activity, but I can only open the Activity without passing the data of this client.
Can you help me?
The code is attached. In this Activity he selects an item from the list and plays the client object for a second Activity, which serves only to query the data:
public class AgendadoDiaActivity extends AppCompatActivity {
private ListView listadeAtendimentos;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_agendado_dia);
listadeAtendimentos = (ListView) findViewById(R.id.lista_atendimentos);
listadeAtendimentos.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> lista, View item, int position, long id) {
Clientes cliente = (Clientes) listadeAtendimentos.getItemAtPosition(position);
Intent pesquisa = new Intent(AgendadoDiaActivity.this, ViewCadastroAtendimentosActivity.class);
pesquisa.putExtra("cliente", cliente);
startActivity(pesquisa);
}
});
In onCreate of this Activity it takes the object I sent in the extra and populates through the method filler() the items in the list.
public class Viewcadastromeets Activity extends Appcompatactivity {
private HelperViewCadastroAtendimentos helper;
private HelperCadastroAtendimentos helperCadastro;
private Clientes cliente;
private Intent pesquisa;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_cadastro_atendimentos);
helper = new HelperViewCadastroAtendimentos(this);
pesquisa = getIntent();
cliente = (Clientes) pesquisa.getSerializableExtra("cliente");
if(cliente != null){
helper.preencheFormulario(cliente);
}
}
In this Activity has an edit button, which calls another edit Activity. It is in it that I cannot take these same dice and play the values of the comic.
To use
putExtra()
with class Customers it should implement the Serializable interaction or preferably the Parcelable interface, see in this reply how to implement it.– ramaral