I'm looking for all Internet about how sending a custom object using an Intent inside of an setOnItemClickListener
. I want to send this Person
Object to another Activity, but it's always sending null. I need to put it in 6 EditText different. Can someone help me?
listEndereco.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(AdrressApp.this, EditorPerson.class);
Person pessoa = listEndereco.getItemAtPosition(position);
intent.putExtra("pessoa", pessoa);
startActivity(intent);
}
});
Here is the another activity:
Intent i = getIntent();
Person idPessoa = (Person) i.getSerializableExtra("pessoa");
When I run the app I get this error:
Attempt to invoke virtual method 'void android.widget.EditText.setText(java.lang.CharSequence)' on a null object reference