我有一个调用子 Activity 的父 Activity,并且在 onActivityResult() 中,当它尝试 setContentView(R.drawable.color_syncing) 时出现 ResourceNotFound 异常。我可以对视图进行其他操作,但不能使用 R 中的任何资源。知道为什么吗?
在主课..
Intent wifiHelperIntent = new Intent(context,WifiHandlerActivity.class);
startActivityForResult(wifiHelperIntent, WIFI_HANDLER_SUB_ACTIVITY_ID);
在子类中:
private void doFinish() {
log("Finishing wifi...");
setResult(RESULT_OK);
finish();
}
然后回到主类:onActivityResult:
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case WIFI_HANDLER_SUB_ACTIVITY_ID:
MonollaLog.log("In onActivityResult from WIFI_HANDLER");
setContentView(R.drawable.color_syncing);
return;
default:
throw new RuntimeException("Unrecognized sub activity request code: "
+ requestCode);
}
}
错误堆栈跟踪:[我在子活动开始之前成功使用此文件]
11-28 14:56:26.312: E/AndroidRuntime(27346): java.lang.RuntimeException: 将结果 ResultInfo{who=null, request=1, result=1, data=null} 传递给活动 {com.monolla. mfbcolor/com.monolla.mfbcolor.MainActivity}:android.content.res.Resources$NotFoundException:来自 xml 类型布局资源 ID #0x7f020003 的文件 res/drawable/color_syncing.jpg