我正在尝试实现自定义标题栏:这是我的助手类: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); } }}这是我在onCreate()中称呼它的地方:@Overridepublic void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setupUI();}private void setupUI(){ setContentView(R.layout.main); UIHelper.setupTitleBar(this);}但是我得到了错误:requestFeature() must be called before adding content
3 回答
月关宝盒
TA贡献1772条经验 获得超5个赞
我正在扩展DialogFragment,以上答案没有用。我必须使用getDialog()实现删除标题:
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
- 3 回答
- 0 关注
- 990 浏览
添加回答
举报
0/150
提交
取消