我正在与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
之后调用