android资源:菜单和assets
2015-07-24 10:12
567 查看
1、菜单(menu)
1、menu\menu.xml中定义
View Code
二、assets资源读取
1、在assets中放置文件.
2、activity中读取
InputStream is = getBaseContext().getAssets().open(DBService.DB_NAME);
1、menu\menu.xml中定义
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.showDialog) { new AlertDialog.Builder(this).setTitle("测试").setPositiveButton("关闭", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(MainActivity.this, "showDialog", Toast.LENGTH_SHORT).show(); } }).show(); } if (id == R.id.showToast) { Toast.makeText(this, "toast", Toast.LENGTH_SHORT).show(); } return super.onOptionsItemSelected(item); }
View Code
二、assets资源读取
1、在assets中放置文件.
2、activity中读取
InputStream is = getBaseContext().getAssets().open(DBService.DB_NAME);
相关文章推荐
- Android软件开发之发送短信与系统短信库解析
- Android Support简介
- android调用浏览器传输地址
- Android Canvas drawText实现中文垂直居中
- android 列表图片优化经历
- Android 系统属性SystemProperty分析
- android多渠道打包牛B工具
- 如何定位Android NDK开发中遇到的错误
- Android中dp,px,sp概念梳理以及如何做到屏幕适配
- androidStudio 使用SVN操作方法
- iOS 与 Android 生命周期对比
- Android -- EventBus
- Google 发布 Android 性能优化典范
- Android性能测试 一些适用于Android Studio的代码审查和性能测试工具
- Android ListView下拉/上拉刷新:设计原理与实现
- Android NDK开发环境配置
- android4.4 wifi 扫描流程分析
- android 自适应 多屏幕支持 --Android多分辨率适配
- Android之发送短信和接收验证码
- Android之发送短信和接收验证码 分类: Android 2015-07-24 09:33 18人阅读 评论(0) 收藏