适配器添加到菜单

适配器添加到菜单

我正在与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);
}

最佳答案

我发现答案仅适用于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之后调用

08-07 00:56