Android底部菜单导航栏_顶部导航栏_侧滑菜单栏源代码
程序员文章站
2022-03-01 13:49:44
...
本Demo是一个大体的安卓app开发UI框架源码、实现了包括底部菜单栏、顶部上方导航栏、仿微信右上角弹出菜单和右划个人中心菜单等、项目有部分注释、感兴趣的可以自己下载研究一下、可以集成到自己的项目里面去、话不我说、直接上图
setUpMenu代码
private void setUpMenu() { rg=(RadioGroup)findViewById(R.id.rg); rb1=(RadioButton)findViewById(R.id.rb1); rb2=(RadioButton)findViewById(R.id.rb2); rb3=(RadioButton)findViewById(R.id.rb3); rb4=(RadioButton)findViewById(R.id.rb4); rb5=(RadioButton)findViewById(R.id.rb5); rg.setOnCheckedChangeListener(this); rb1.setChecked(true); // attach to current activity; resideMenu = new ResideMenu(this); resideMenu.setBackground(R.drawable.menu_background); resideMenu.attachToActivity(this); resideMenu.setMenuListener(menuListener); // valid scale factor is between //0.0f and 1.0f. leftmenu´width is // 150dip. resideMenu.setScaleValue(0.6f); // 禁止使用右侧菜单 resideMenu.setDirectionDisable(ResideMenu .DIRECTION_RIGHT); // create menu items; itemGuanZhangEmail = new ResideMenuItem(this, R.drawable.icon_profile, "馆长信箱"); itemGrRenXinXi = new ResideMenuItem(this, "我的信息"); itemZhuangban = new ResideMenuItem(this, "当前查看"); itemShoucang = new ResideMenuItem(this, "借阅记录"); itemXiangce = new ResideMenuItem(this,"预约查询"); itemFile = new ResideMenuItem(this,"违章查询"); resideMenu.addMenuItem(itemGuanZhangEmail, ResideMenu.DIRECTION_LEFT); resideMenu.addMenuItem(itemGrRenXinXi, ResideMenu.DIRECTION_LEFT); resideMenu.addMenuItem(itemZhuangban, ResideMenu.DIRECTION_LEFT); resideMenu.addMenuItem(itemShoucang, ResideMenu.DIRECTION_LEFT); resideMenu.addMenuItem(itemXiangce, ResideMenu.DIRECTION_LEFT); resideMenu.addMenuItem(itemFile, ResideMenu.DIRECTION_LEFT); info = new ResideMenuInfo(this, R.drawable.icon_profile, "我我我", "2012012147"); }
监听手机上的BACK键
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { // 判断菜单是否关闭 if (is_closed) { // 判断两次点击的时间间隔(默认设置为2秒) if ((System.currentTimeMillis() - mExitTime) > 2000) { Toast.makeText(this, "再按一次退出程序", Toast.LENGTH_SHORT).show(); mExitTime = System.currentTimeMillis(); } else { finish(); System.exit(0); super.onBackPressed(); } } else { resideMenu.closeMenu(); } return true; } return super.onKeyDown(keyCode, event); }
最后给贴上Demo的源代码、希望对大家有用、有兴趣的哥们可以下载看看
源代码下载链接: http://dwtedx.com/download.html?bdkey=s/1dDlOAOx 密码: nemt