我正在尝试使用自定义标题在标题栏中包含一个图像按钮。 我从这篇文章中得到了很多帮助:android: adding button to the title of the app? ,但无法让它适用于我的 ListActivity。
简而言之,以下是我所拥有的:
- 我在 AndroidManifest.xml 中隐藏了标题栏
为自定义标题指定相对布局(workorder_list_titlebar.xml)
我的 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/