1
我正在使用以下代碼。在子活動完成後無法調用onactivity結果函數
addNewReceipt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent myIntent = new Intent(v.getContext(), AddReceipt.class);
myIntent.putExtra("receiptList", receipts);
startActivityForResult(myIntent, RECEIPT_ADD);
}
});
}
@SuppressWarnings("unchecked")
public synchronized void onActivityResult(final int requestCode, int resultCode, final Intent data)
{
if (resultCode == Activity.RESULT_OK)
{
if (requestCode == RECEIPT_ADD)
{
receipts = (ArrayList<Receipt>) data.getSerializableExtra("receiptList");
addReceiptsInListView();
}
}
}
爲AddReceipt類的代碼如下,
@Override
public void finish() {
Intent data = new Intent();
data.putExtra("receiptList", receipts);
setResult(RESULT_OK, data);
super.finish();
}
@SuppressWarnings("unchecked")
public void onCreateCall()
{
done.setOnClickListener(new OnClickListener()
{ //receiptAddBtn
@Override
public void onClick(View v)
{
String error = "";
Receipt receipt = new Receipt();
receipt.comments = comments.getText().toString();
receipt.referenceNo = receiptNo.getText().toString();
receipt.image = imageSelected;
if (receipt.image == null || receipt.referenceNo == "")
{
error = "Please input Receipt No. and attach Image";
displayAlert(error);
}
else
{
receipts.add(receiptCounter,receipt);
finish();
}
}
});
}
的問題是,當活動結束後...我通過這個收據,我在以前的類從我稱之爲活動public synchronized void onActivityResult
從來沒有工作。
後退按鈕還沒有結束活動。
請告訴我我錯在哪裏。
問候
是否連進onActivityResult呢? (不管響應代碼等) – Soham 2012-03-06 07:44:46
是'onActivityResult(...)'調用?也許根本不同'resultCode'甚至根本不? – triad 2012-03-06 07:45:59
沒有打電話在所有..哦,太棒了,它與下面的代碼,現在和以前一樣想找到大聲笑! – 2012-03-06 07:48:27