更新时间:2022-10-18 19:28:40
好了,只是做了错误消息告诉你。
不要叫的setContentView()
在 requestFeature()
。
注意:
正如评论所说,对于 ActionBarSherlock
和 AppCompat
库,它需要调用 requestFeature()
在 super.onCreate()
I am trying to implement a custom titlebar:
Here is my Helper class:
import android.app.Activity;
import android.view.Window;
public class UIHelper {
public static void setupTitleBar(Activity c) {
final boolean customTitleSupported = c.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
c.setContentView(R.layout.main);
if (customTitleSupported) {
c.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar);
}
}
}
Here is where I call it in onCreate():
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setupUI();
}
private void setupUI(){
setContentView(R.layout.main);
UIHelper.setupTitleBar(this);
}
But I get the error:
requestFeature() must be called before adding content
Well, just do what the error message tells you.
Don't call setContentView()
before requestFeature()
.
Note:
As said in comments, for both ActionBarSherlock
and AppCompat
library, it's necessary to call requestFeature()
before super.onCreate()
android.util.AndroidRuntimeException:requestFeature()必须在添加内容之前调用
只有LINQ to Entities中的排序输入才支持“Skip”方法。必须在方法“跳过”之前调用“OrderBy”方法
分页错误:方法“跳过”仅支持LINQ to Entities中的排序输入。必须在方法“跳过”之前调用“OrderBy”方法
ImproperlyConfigured:您必须在访问设置之前定义环境变量 DJANGO_SETTINGS_MODULE 或调用 settings.configure()
不正确配置:您必须在访问设置之前定义环境变量DJANGO_SETTINGS_MODULE或调用settings.configure()