gpt4 book ai didi

android - 自定义标题栏-Android崩溃

转载 作者:行者123 更新时间:2023-12-03 12:24:15 24 4
gpt4 key购买 nike

我正在尝试为我的应用程序创建自定义标题栏。问题是,如果我进行以下更改,它将在启动时崩溃:

    this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
this.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar);

可能是什么问题?我已经搜索了论坛和网络,但找不到答案。谢谢。

最佳答案

设置标题栏后尝试调用 setContentView(...)

this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);    
this.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar);
setContentView(R.layout.main);

关于android - 自定义标题栏-Android崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11940205/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com