android - 尝试使用 Window.FEATURE_CUSTOM_TITLE 但得到 Exception :You cannot combine custom titles with other title feature. 。

标签 android

我正在尝试使用自定义标题在标题栏中包含一个图像按钮。 我从这篇文章中得到了很多帮助:android: adding button to the title of the app? ,但无法让它适用于我的 ListActivity。

简而言之,以下是我所拥有的:

  1. 我在 AndroidManifest.xml 中隐藏了标题栏
  2. 为自定义标题指定相对布局(workorder_list_titlebar.xml)

  3. 我的 Activity 类如下所示:

    public class WorkOrderListActivity extends ListActivity {
     String[] orders={"WO-12022009", "WO-12302009","WO-02122010", "02152010"};
     @Override
     public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);   
       requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
       this.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.workorder_list_titlebar);
       setContentView(R.layout.workorder_list);
       setListAdapter(new ArrayAdapter(this,R.layout.workorder_list, R.id.label,orders));    
            }
    }

当我运行应用程序时,我得到了 AndroidRuntimeException: You cannot combine custom title with other title features。

根据堆栈跟踪,该异常是由 setlistAdapter 调用触发的 com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:183) 引发的。

有没有人对 ListActivity 有同样的问题? 此外,一旦我设法完成这项工作,如何将监听器附加到图像按钮以使其执行某些操作?

提前致谢。

最佳答案

我遇到了同样的问题,我修复它删除

<item name="android:windowNoTitle">true</item>

来 self 的 theme.xml

关于android - 尝试使用 Window.FEATURE_CUSTOM_TITLE 但得到 Exception :You cannot combine custom titles with other title feature. 。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2686556/

相关文章:

java - Jenkins html 发布者插件显示旧的缓存 html——不是更新的

android - 图标到边缘

android - 有没有办法混合 Android View ?

android - 无法导入 facebook sdk,与 google play 服务冲突

android - Galaxy S4 "Make Bug Report"对话框从不初始化

android - 带有 facebook sdk 登录的闪屏需要 nohistory=false (我需要 nohistory=true)

java - 从sqlite数据库Android检索数据时捕获异常

android - 每 1/10 秒获取一次传感器数据

android - 为 MapView 设置最小缩放级别

Android Webview - 重定向时给出 'Object moved to'