Android intent传递hashMap对象,遍历hashMap,改变menu状态
来源:互联网 发布:动漫绘图软件 编辑:程序博客网 时间:2024/06/06 03:46
大家可以查看Intent可以传递的参数,有String,int,Boolean,Serializable等,就是不能直接传递HashMap时首先封装自己的HashMap对象:
然后用Bundle传递封装的对象:
最后获取:
HashMap的遍历有两种常用的方法,那就是使用keyset及entryset来进行遍历,但两者的遍历速度是有差别的
第一种:
效率高,以后一定要使用此种方式!
第二种:
效率低,以后尽量少使用!
对于keySet其实是遍历了2次,一次是转为iterator,一次就从hashmap中取出key所对于的value。而entryset只是遍历了第一次,他把key和value都放到了entry中,所以就快了
只被初始化一次(通常这么认为),则用下面的方法
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = this.getMenuInflater();
inflater.inflate(R.menu.menu, menu);
menu.findItem(R.id.sort_by_name).setChecked(true);
}
findViewById()用于menu ,因为他是menu,不是view. 我们可以更改menu的状态,只有它已经被创建或是被准备( created or prepared)好后才行。
0 0
- Android intent传递hashMap对象,遍历hashMap,改变menu状态
- Android笔记—Intent传递序列化HashMap对象
- Intent传递HashMap数据
- android intent传递HashMap<String, Object>
- HashMap对象的遍历
- android的HashMap遍历
- HashMap对象两种遍历
- HashMap、TreeMap对象的遍历
- 遍历HashMap
- HashMap遍历
- 遍历HashMap
- 遍历HashMap
- 遍历hashmap
- HashMap 遍历
- 遍历hashMap
- HashMap遍历
- 遍历hashmap
- HashMap遍历
- 十二.js 截取字符串
- NAV导航网格寻路(7) -- 代码和一些优化
- 监听文本框内容改变事件oninput,onpropertychange,onchange的用法和区别
- Android应用安装时因签名问题不能安装的解决方法
- 安装composer时Warning: readfile(): SSL operation failed with code 1. OpenSSL Error messages:
- Android intent传递hashMap对象,遍历hashMap,改变menu状态
- linux 文件属性与权限
- 百度ECharts---android在线展示统计图表(折线图\柱状图\饼状图)
- 布线问题
- centos查看IP地址
- 成功安装mysql后,为何服务管理器里找不到MYSQL服务名
- 分布式资源整理(未完成)
- spring通配符工具类
- Java开发报表导入,导出小工具类