我尝试在setContent方法之前和之后添加,但面对问题仍然是“android.util.AndroidRuntimeException:requestFeature()必须在添加内容之前调用 “
public void onNewIntent(Intent intent){
final boolean customTitleSupported =
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
super.onNewIntent(intent);
session = new SessionManagement(getApplicationContext());
if(customTitleSupported){
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.item);
}
setContentView(R.layout.itemlist);
setIntent(intent);
答案 0 :(得分:1)
在致电requestWindowFeature(Window.FEATURE_CUSTOM_TITLE)
之前,您应致电setContentView()
。 super.onCreate()
中onCreate
方法 Activity
之前的好地方。