use of com.szu.androidpractice.adapter.DrawerListAdapter in project AndroidPractice by lguipeng.
the class SlideMenuFragment method init.
private void init() {
final List<String> list = new ArrayList<>();
list.add("Spring");
list.add("Summer");
list.add("Autumn");
list.add("Winter");
DrawerListAdapter adapter = new DrawerListAdapter(getActivity(), list);
mDrawerMenuListView.setAdapter(adapter);
mDrawerMenuListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mCurrentTitlePosition = position;
mDrawerMenuListView.setItemChecked(position, true);
mDrawerLayout.closeDrawer(parent);
}
});
mDrawerMenuListView.setItemChecked(mCurrentTitlePosition, true);
setTitle(list.get(mCurrentTitlePosition));
mDrawerToggle = new ActionBarDrawerToggle(getActivity(), mDrawerLayout, 0, 0) {
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
activity.invalidateOptionsMenu();
setTitle(R.string.slide_menu);
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
activity.invalidateOptionsMenu();
setTitle(list.get(mCurrentTitlePosition));
}
};
mDrawerToggle.setDrawerIndicatorEnabled(true);
mDrawerLayout.setDrawerListener(mDrawerToggle);
mDrawerLayout.setScrimColor(getColor(R.color.window_background));
}
Aggregations