我试图用一个自定义标题包含图片按钮标题栏。 我得到了很多的帮助形式这篇文章:http://stackoverflow.com/questions/2569753/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(包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(新ArrayAdapter(这一点,R.layout.workorder_list,R.id.label,订单)); } }
当我跑的应用程序,我得到了AndroidRuntimeException:不能将自定义标题与其他标题的功能。
此基础上的堆栈跟踪,异常是由com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:183)抛出,这是由setlistAdapter呼叫触发。
有没有人有同样的问题ListActivity? 还有一次,我设法得到这个工作,我怎么重视听众图像按钮为它做什么?
在此先感谢。
解决方案我有同样的问题,我解决它删除
<项目名称=机器人:windowNoTitle>真< /项目>
这是我的 theme.xml
I am trying to use a custom title to include an image button to the title bar. I got a lot of help form this post: http://stackoverflow.com/questions/2569753/android-adding-button-to-the-title-of-the-app, but could not get it work for my ListActivity.
In a nutshell, following is what I have:
I hide the titlebar in the AndroidManifest.xmlThe specify a relative layout for the custom title (workorder_list_titlebar.xml)
My Activity Class looks like the following:
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)); } }
When I ran the app, I got AndroidRuntimeException: You cannot combine custom titles with other title features.
Base on the stack trace, the exception was thrown by com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:183), that was triggered by setlistAdapter call.
Does anyone have the same problem with ListActivity? Also once I manage to get this work, how do I attach listeners to the image button for it to do something?
Thanks in advance.
解决方案I had the same issue and I fix it deleting
<item name="android:windowNoTitle">true</item>
from my theme.xml