Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.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 在ActionBar上显示自定义按钮夏洛克以显示滑动菜单_Android_Actionbarsherlock_Slidingmenu - Fatal编程技术网

Android 在ActionBar上显示自定义按钮夏洛克以显示滑动菜单

Android 在ActionBar上显示自定义按钮夏洛克以显示滑动菜单,android,actionbarsherlock,slidingmenu,Android,Actionbarsherlock,Slidingmenu,我正在开发一个Android应用程序,使用 现在,我显示打开菜单的按钮: 但不希望在左侧显示

我正在开发一个Android应用程序,使用

现在,我显示打开菜单的按钮:

但不希望在左侧显示<,并将其图标更改为自定义图标

这是我设置滑动菜单的方式:

private void setUpSlidingMenuAndActionBar()
{
    setBehindContentView(R.menu.menu);

    setSlidingActionBarEnabled(true);        

    slidingMenu = getSlidingMenu(); 
    slidingMenu.setMode(SlidingMenu.LEFT);
    slidingMenu.setSlidingEnabled(false);
    slidingMenu.setBehindOffset(100);

    getSupportActionBar().setDisplayShowCustomEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
如何删除左侧的<图标并更改主页按钮图标?

当我点击那个按钮时,我打开了滑动菜单

更新:

<application
    [ ... ]
    android:theme="@style/AppTheme.ActionBarStyle" >
下面是黑带回答,我就是这么做的:

styles.xml

<style name="AppTheme.ActionBarStyle" parent="@style/Theme.Sherlock">
    <item name="android:homeAsUpIndicator">@drawable/but_menu</item>
    <item name="homeAsUpIndicator">@drawable/but_menu</item>
</style>

@可绘图/但菜单
@可绘图/但菜单
Manifest.xml:

<application
    [ ... ]
    android:theme="@style/AppTheme.ActionBarStyle" >

结果是:


我可以看到绿色的机器人!!!我不想看到它

使用homeAsUpIndicator内部样式

 <item name="android:homeAsUpIndicator">@drawable/home_up_drawable</item>
 <item name="homeAsUpIndicator">@drawable/home_up_drawable</item>
@drawable/home\u up\u drawable
@可拉拔/自上可拉拔
我的看起来像:

<style name="AppTheme.ActionBarStyle" parent="@style/Widget.Sherlock.ActionBar.Solid">
    <item name="android:homeAsUpIndicator">@drawable/home_up_drawable</item>
    <item name="homeAsUpIndicator">@drawable/home_up_drawable</item>
    <item name="android:titleTextStyle">@style/AppTheme.TitleTextStyle</item>
    <item name="android:background">@drawable/actionbar_background</item>
    <item name="background">@drawable/actionbar_background</item>
    <item name="android:displayOptions">showHome|useLogo</item>
    <item name="displayOptions">showHome|useLogo</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="windowContentOverlay">@null</item>
</style>

@可拉拔/自上可拉拔
@可拉拔/自上可拉拔
@style/AppTheme.TitleTextStyle
@可绘制/操作栏\u背景
@可绘制/操作栏\u背景
showHome | useLogo
showHome | useLogo
@空的
@空的

您可以创建自定义操作栏,并可以更改其图标以进行自定义

按照以下步骤操作:

只有这样才能为标题创建自定义Sherlock栏

为应用程序上的标题创建单独的xml文件

该文件包含如下内容

在此自定义布局中,我们可以更改背景颜色和自定义图标

您只需将图像从drawable添加到头文件\u sherlock.xml文件按钮编码部分,如 android:background=“@drawable/imageName”

header_sherlock.xml

     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="3"
android:background="#008000"
 >

     <Button
    android:id="@+id/header_tvleft"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:gravity="left"
    android:layout_marginTop="@dimen/margintop"
    android:clickable="true"
    android:paddingLeft="@dimen/layoutpaddingleft"
    android:text="Back"
    android:background="@drawable/imageName"
    android:textColor="#ffffff" 
    android:textSize="@dimen/header_leftbtn"
     /> 


<Button
    android:id="@+id/header_tvcenter"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:gravity="center_horizontal"
    android:layout_marginTop="@dimen/margintop"
    android:layout_marginRight="@dimen/sherlockpaddingright"   
    android:layout_marginLeft="@dimen/sherlockpaddingleft"
    android:text="Center"
    android:textColor="#ffffff"
    android:textStyle="bold"
    android:background="@drawable/save1"
    android:textSize="@dimen/header_title"
     />

    <Button
    android:id="@+id/header_tvright"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:gravity="right"
    android:layout_marginTop="@dimen/margintop"
    android:clickable="true"
    android:paddingRight="@dimen/layoutpaddingright"
    android:text="Right"
    android:textColor="#ffffff"
    android:background="@drawable/save1"
    android:textSize="@dimen/header_rightbtn"
     />

 </LinearLayout>
//在这个按钮监听器代码里面,我们可以设置滑动菜单编码

 header_tvleft.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
    // inside you will able to set your sliding menu whatever.......                

        }
    });
注意:这仅适用于创建自定义操作栏


如果您想进一步澄清,我想回答您的问题……

谢谢您的回答,但我对这一点非常陌生。我必须在哪里添加它?在styles.xml中。有安卓系统的物品:用于本机操作栏支持,没有安卓系统的物品用于夏洛克。我已经更新了我的问题,并提供了更多详细信息。使用您的答案,我仍然可以看到绿色的android机器人。尝试添加@null@nullI,在运行时使用getSupportActionBar().setIcon(android.R.color.transparent)删除它;您好,当右键点击右键点击右键点击右键点击左键点击左键点击右键点击右键点击左键点击左键点击右键点击右键点击右键点击右键点击右键点击右键点击右键点击右键点击右键点击右键点击右键点击右键点击右键点击右键点击右键点击右键点击右键点击右键点击右键点击。当我们看到幻灯片菜单时,首先单击左侧菜单,然后菜单将转到同一菜单的右侧。然后,当你们点击右边的同一个菜单时,它会再次出现在左边。就是这样。看任何幻灯片菜单程序的例子。理解它可能会有用。谢谢,但现在我已经解决了我的问题。就我而言,我有两个滑动菜单。我喜欢左边,另一个是右边,就像facebook一样。