android smartbar适配
来源:互联网 发布:淘宝信誉评级是什么 编辑:程序博客网 时间:2024/06/03 13:09
1.使用魅族的demo里的SmartBarUtils.java
android:theme="@android:style/Theme.DeviceDefault.Light" android:uiOptions="splitActionBarWhenNarrow"
public static void setActionBarTabsShowAtBottom(ActionBar actionbar, boolean showAtBottom) { try { Method method = Class.forName("android.app.ActionBar").getMethod( "setTabsShowAtBottom", new Class[] { boolean.class }); try { method.invoke(actionbar, showAtBottom); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } } public static void setActionBarViewCollapsable(ActionBar actionbar, boolean collapsable) { try { Method method = Class.forName("android.app.ActionBar").getMethod( "setActionBarViewCollapsable", new Class[] { boolean.class }); try { method.invoke(actionbar, collapsable); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } } public static void setActionModeHeaderHidden(ActionBar actionbar, boolean hidden) { try { Method method = Class.forName("android.app.ActionBar").getMethod( "setActionModeHeaderHidden", new Class[] { boolean.class }); try { method.invoke(actionbar, hidden); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } catch (SecurityException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } }
2.在mainifest中的Application
3.在基类的activity中:
//代表隐藏头部bar
SmartBarUtils.setActionBarViewCollapsable(getActionBar(), true);
getActionBar().setDisplayOptions(0);
4.在业务的fragment中:
必须先调用下面的代码,才能是fragment里的menu生效
setHasOptionsMenu(true);
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.home_menu, menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_home_page:
new AlertDialog.Builder(mAct).setTitle("Action Menu Item")
.setPositiveButton("Yes", null).setNegativeButton("Cancel", null).show();
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}
魅族的反射工具类:
public class SmartBarUtils {
0 0
- android smartbar适配
- Android 适配魅族去掉smartbar
- 魅族smartbar 适配
- Android-取得输入法或者系统标题栏、魅族下部smartbar等的高度
- Android 判断当前系统是否是魅族系统,并获取SmartBar的高度
- actionBar适配魅族smartBar
- 隐藏魅族手机的smartbar
- 获取魅族底部smartbar的高度
- 【开源项目】Smart,让魅族Smartbar变得Smart,Version:2.0
- Smartbar 自动隐藏,任务栏显示网速 电量带百分比符号
- android适配
- Android 适配
- android适配
- Android适配
- android适配
- android适配
- android 适配
- Android适配
- 一步一步教你做iOS推送
- Qt开发的sqlite数据库应用出现Driver not loaded
- 01背包问题
- 关于vim复制剪贴粘贴命令的总结
- hihoCoder#1089 最短路径·二
- android smartbar适配
- java的反射机制
- C++中的数串转换
- iOS 在任意界面 Dismiss Keyboard
- 研发管理08:敏捷 Scrum 相关基本概念
- 数据结构 - 数组
- MongoDB:too much data for sort() with no index error异常
- 在 CentOS 和 RHEL 上安装 Puppet 服务器和客户端
- android使用ksoap2调用webservice接口返回错误HTTP status: 500