【问题标题】:Try to use Window.FEATURE_CUSTOM_TITLE but got Exception:You cannot combine custom titles with other title feature..尝试使用 Window.FEATURE_CUSTOM_TITLE 但出现异常:您不能将自定义标题与其他标题功能结合使用..
【发布时间】:2010-04-21 21:04:45
【问题描述】:
我正在尝试使用自定义标题在标题栏中包含一个图像按钮。
我在这篇文章中得到了很多帮助:android: adding button to the title of the app?,但无法让它为我的 ListActivity 工作。
简而言之,以下是我所拥有的:
- 我在 AndroidManifest.xml 中隐藏了标题栏
为自定义标题指定相对布局(workorder_list_titlebar.xml)
我的活动类如下所示:
公共类 WorkOrderListActivity 扩展 ListActivity {
String[] 订单={"WO-12022009", "WO-12302009","WO-02122010", "02152010"};
@覆盖
公共无效 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 有同样的问题?
另外,一旦我设法完成这项工作,如何将侦听器附加到图像按钮以使其执行某些操作?
提前致谢。
【问题讨论】:
标签:
android