Android SlidingMenu将适配器添加到菜单中

时间:2013-01-08 09:11:25

标签: android android-menu

我正在与Sliding Menu合作,需要专业人士的帮助!我想用ListView适配器添加菜单(布局)。我看到了演示应用,它是在Fragment构建的,但是我的应用extends SlidingActivity我无法理解如何操纵MenuView

MainActivity.class

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // MainView, MenuView
    setContentView(R.layout.main);
    setBehindContentView(R.layout.main_menu);

    //SlidingMenu
    mMainMenu = (ListView) findViewById(R.id.main_menu);
    mMenuAdapter = new MenuAdapter(this, R.id.menu_adapter_title);
    mMainMenu.setAdapter(mMenuAdapter);
}

1 个答案:

答案 0 :(得分:2)

我发现只有ArrayAdapter才能解决它的问题! 如果它有帮助它是我的代码

private void populate() {

    ListView lv = (ListView) findViewById(R.id.main_menu);
    String[] menu = {"Главная","Кино","Театры","Вечеринки","Концерты","Выставки","Рестораны","Магазины","Фотографии","Каталог","Погода"};
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            R.layout.main_menu_adapter, R.id.menu_adapter_title, menu);
    lv.setAdapter(adapter);

}

并在setBehindContentView

之后调用它