,有水平线条表格,有柱状表格等。
由LineFragment,BarFragment,StackedFragment,SandboxFragment几个fragment封装实现几种效果。DrawerFragment来实现简单框架。并且提供接口项目部分如下:
/**
* Callbacks interface that all activities using this fragment must implement. */ public interface NavigationDrawerCallbacks {void onNavigationDrawerItemSelected(int position);
}给首页回调。
首页MainActivity implements DrawerFragment.NavigationDrawerCallbacks实现方法用来切换fragment @Override public void onNavigationDrawerItemSelected(int position) {switch (position){
case 0: getSupportFragmentManager().beginTransaction() .replace(R.id.container, new LineFragment()) .commit(); break; case 1: getSupportFragmentManager().beginTransaction() .replace(R.id.container, new BarFragment()) .commit(); break; case 2: getSupportFragmentManager().beginTransaction() .replace(R.id.container, new StackedFragment()) .commit(); break; case 3: mCurrFragment = new SandboxFragment(); getSupportFragmentManager().beginTransaction() .replace(R.id.container, mCurrFragment) .commit(); default: break; } }运行效果:
文章来自作者原创,转发请标明出处,谢谢。