Person 유형의 객체가있는 ArrayList가 있습니다. Person 클래스에는 필드 이름, 주소 1, 주소 2, 도시, 주, 우편 번호 및 국가가 있습니다. 특정 인물을 편집 한 다음 Person을 표시하는 ListAdapter가 업데이트 된 데이터를 표시하도록 변경 사항을 업데이트 할 수 있기를 원합니다. Current_Recipient를 얻을 활동 BI에서ListView의 CustomListAdapter 클래스에서 인 텐트의 결과를 얻는 방법
holder.txtRecName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent rec_Intent = new Intent(context,
RecipientAddressActivity.class);
rec_Intent.putExtra("Current_Recipient",
recipientArray.get(index));
rec_Intent.putExtra("RecipientIndex",index);
context.startActivity(rec_Intent);
}
});
이있는 ListView는 내가 텍스트 뷰의 onClick 이벤트의 의도를 사용하여 활동 RecipientAddressActivity (활동 B)를 시작 사용자 정의 어댑터에서 RecipientActivity (활동 A)
에 포함되어 있습니다 이 같은과에서 onCreate에서 인덱스() 이벤트 : 같은 활동에
current_rec = (Person) getIntent().getSerializableExtra(
"Current_Recipient");
Recipient_Index = getIntent().getIntExtra("RecipientIndex", 151);
, 내가 가진 버튼 "저장"과의 onclick 나는 새로운 사람이나 늙은 사람이 될 수있는 Person 객체를 생성 자사에 편집 중입니다.
저장 버튼의 OnClick() 이벤트
{
Intent Recipient_info = new Intent();
Person recipient = new Person(edt_rec_name.getText().toString(),
edt_rec_addr1.getText().toString(),edt_rec_addr2.getText().toString(),
edt_rec_city.getText().toString(), edt_rec_state.getText().toString(),
edt_rec_pcode.getText().toString(), edt_rec_country.getText().toString());
Recipient_info.putExtra("Person", recipient);
Recipient_info.putExtra("RecipientIndex", Recipient_Index);
setResult(RESULT_OK, Recipient_info);
finish();
}
문제는 그 방법이나 위치 Actvity B가있는 ListView의 어댑터를 사용하기 시작하면 결과를 잡으려고 모르는 활동 B를 시작하는 2 가지 방법이 있습니다입니다.
최대한 빨리 도와주세요. 더 많은 코드 나 설명이 필요한지 알려 주시기 바랍니다.
감사합니다.
당신이 activityForResult
로 활동을 시작되지 않습니다
당신의 Person 클래스는 parcelable 구현 하는가? – Raghunandan
@Raghunandan 아니요 Serializable을 구현하고 있지 않습니다. 안드로이드 parcelable에 대한 – user2688158
은 serializable보다 낫다. googe 예제를 찾고 자습서를 따르십시오. – Raghunandan