2013-11-27 53 views
1

我想创建一个实现MenuDrawer(使用SimonVT的android-menudrawer库)的应用程序。如何在menudrawer中设置活动元素的背景颜色

我开始使用示例左菜单作为基础。它使用箭头来指示哪个元素处于活动状态。

我的问题是,我怎样才能使活动项目显示不同颜色的背景,而不是图像。

+0

看到这里http://stackoverflow.com/questions/15810316/highlighting-selected-item-in -menu-drawer-sliding-menu – Hardik

+0

对于类型View,未定义方法setSelectionHandlerColorResource(),并且问题未解决 – xAnubiSx

回答

0

在您的适配器放在一边getView()view.setSelectionHandlerColorResource(Set your color here);

类似如下:

public View getView(int position, View convertView, ViewGroup parent) { 
    view.setSelectionHandlerColorResource(Set your color here); 
} 
+0

未定义类型视图的方法setSelectionHandlerColorResource() – xAnubiSx

+0

替换为用于设置您的颜色的等效方法方法。 – Yup

+0

是的,这可能是一种替代方法,方法是view.setBackgroundColor(color)。正如我所看到的,图书馆是不可能的。 我将不得不实现一些代码来重置默认背景并设置所选项目的背景。 – xAnubiSx