【发布时间】:2014-01-11 23:52:34
【问题描述】:
我正在尝试将设置片段添加到我的 android-app。 所以,我添加了一个 xml 文件和这个活动:
public class SettingsActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Display the fragment as the main content.
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsFragment())
.commit();
}
public static class SettingsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
}
}
}
它是从主活动中的 onOptionsItemSelected 函数调用的:
if (id == R.id.action_settings) {
Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
return true;
}
所以,现在,当我尝试从菜单打开活动时,它会强制关闭,并且我在控制台中收到此错误:
Force-removing child win Window{4190a9a8 u0 PopupWindow:418fc208} from container Window{418dd448 u0 org.name.app/org.name.app.MainActivity}
Failed looking up window
java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@423b1fc0 does not exist
at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:7934)
at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:7925)
at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:1047)
at android.os.BinderProxy.sendDeathNotice(Binder.java:493)
at dalvik.system.NativeStart.run(Native Method)
【问题讨论】:
标签: java android android-activity settings preferences