Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android 4.0或更高版本中显示标题为的操作栏时出现问题_Android_Android Actionbar_Actionbarsherlock - Fatal编程技术网

在android 4.0或更高版本中显示标题为的操作栏时出现问题

在android 4.0或更高版本中显示标题为的操作栏时出现问题,android,android-actionbar,actionbarsherlock,Android,Android Actionbar,Actionbarsherlock,我正在我的应用程序中使用操作栏。我使用sherlock library在android 3.0版下显示操作栏。它工作正常。我想将标题栏添加到我的应用程序中。我执行了以下操作: requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title_layout); 在xml中,我做到了这一点: <style

我正在我的应用程序中使用操作栏。我使用sherlock library在android 3.0版下显示操作栏。它工作正常。我想将标题栏添加到我的应用程序中。我执行了以下操作:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title_layout);
在xml中,我做到了这一点:

<style name="title_theme" parent="@style/Sherlock.__Theme.DarkActionBar">
        <item name="android:windowNoTitle">false</item>
        <item name="android:windowTitleSize">50dip</item>
        <item name="android:windowTitleBackgroundStyle">@style/title_theme</item>
    </style>

可能不需要使用标题栏,因为操作栏支持标题功能,所以您只需添加
getSherlockActivity.getSupportActionBar().setTitle(“一些文本”)
您是否尝试过此

getSherlockActivity.getSupportActionBar().setCustomView(customNav);
getSherlockActivity.getSupportActionBar().setDisplayShowCustomEnabled(true)

查看更新的答案…(sherlock不支持自定义标题,但支持上面两行)谢谢,但不管我在问题中添加了什么代码,尽管它支持自定义标题,但仅在3.0之前,而不是3.0之后。我使用的是SherlockFragmentActivity和getSherlockActivity()不可用。如果您的类使用
SherlockFragment
扩展,则可以使用getSherlockActivity()
You cannot combine custom titles with other title feature..