android中的幻灯片菜单

android中的幻灯片菜单,android,jquery,android-activity,Android,Jquery,Android Activity,我想更改幻灯片菜单的背景 请看下面 我想把黑色换成其他颜色,但我不能帮我 我的密码在这里 activity_main.xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/bg_main

我想更改幻灯片菜单的背景

请看下面

我想把黑色换成其他颜色,但我不能帮我 我的密码在这里

activity_main.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg_main" >

<com.coboltforge.slidemenu.SlideMenu
    android:id="@+id/slideMenu"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >


</com.coboltforge.slidemenu.SlideMenu>

<TextView
    android:id="@+id/textView1"
     android:background="@drawable/bg_top" />

这很简单也很优雅:

只需在可绘制文件夹中创建一个名为“background”的新文件,然后输入所需的XML样式 快速示例:

然后在抽屉中引用这个新文件 android:background=@drawable/background

希望有帮助

import com.coboltforge.slidemenu.SlideMenu;
import com.coboltforge.slidemenu.SlideMenu.SlideMenuItem;
import com.coboltforge.slidemenu.SlideMenuInterface.OnSlideMenuItemClickListener;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

public class MainActivity extends Activity implements OnSlideMenuItemClickListener {

    private SlideMenu slidemenu;
    private final static int MYITEMID = 42;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        /*
         * There are two ways to add the slide menu: 
         * From code or to inflate it from XML (then you have to declare it in the activities layout XML)
         */
        // this is from code. no XML declaration necessary, but you won't get state restored after rotation.
//      slidemenu = new SlideMenu(this, R.menu.slide, this, 333);
        // this inflates the menu from XML. open/closed state will be restored after rotation, but you'll have to call init.
        slidemenu = (SlideMenu) findViewById(R.id.slideMenu);
        slidemenu.init(this, R.menu.slide, this, 333);

        // this can set the menu to initially shown instead of hidden
//      slidemenu.setAsShown(); 

        // set optional header image
        slidemenu.setHeaderImage(R.drawable.headerbanner);

        // this demonstrates how to dynamically add menu items
        SlideMenuItem item = new SlideMenuItem();
        item.id = MYITEMID;
        item.icon = getResources().getDrawable(R.drawable.ic_launcher);
        item.label = "Dynamically added item";
        slidemenu.addMenuItem(item);

        // connect the fallback button in case there is no ActionBar
        Button b = (Button) findViewById(R.id.buttonMenu);
        b.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                slidemenu.show();
            }
        }); 
    }       
}