当前位置: 编程技术>移动开发
本页文章导读:
▪ViewGroup中bringToFront懂得 ViewGroup中bringToFront理解
Android中的ViewGroup是通过一个Array来保存其Children,当调用某个childView的bringToFront时,是将
该childView放在其Parent的Array数组的最后,ViewGroup的dispatchDraw在draw时是按照Array.........
▪ 搅混代码,防止反编译 混淆代码,防止反编译
<!--StartFragment -->
2.3版本以上在eclipse自动生成的default.properties文件中加上一句“proguard.config=proguard.cfg”可以对代码进行混淆
......
▪ java 地图 遍历 java map 遍历
package com.xiawenquan.map.demo;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import com.xiaw.........
[1]ViewGroup中bringToFront懂得
来源: 互联网 发布时间: 2014-02-18
ViewGroup中bringToFront理解
Android中的ViewGroup是通过一个Array来保存其Children,当调用某个childView的bringToFront时,是将 该childView放在其Parent的Array数组的最后,ViewGroup的dispatchDraw在draw时是按照Array从前往后依 次调用drawChild的,这样最后一个childView就在最前面了
[2] 搅混代码,防止反编译
来源: 互联网 发布时间: 2014-02-18
混淆代码,防止反编译
<!--StartFragment -->
<!--StartFragment -->
2.3版本以上在eclipse自动生成的default.properties文件中加上一句“proguard.config=proguard.cfg”可以对代码进行混淆
[3] java 地图 遍历
来源: 互联网 发布时间: 2014-02-18
java map 遍历
package com.xiawenquan.map.demo; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import java.util.Map.Entry; import com.xiawenquan.map.demo.Student; public class TestMap { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub //HashMap无序 LinkedHashMap有序 Map<String, Student> map = new LinkedHashMap<String, Student>(); for(int i = 0 ; i < 10 ; i++){ map.put(i + "", new Student("夏文权_" + i, "北京霍营_" + i, i+1)); System.out.println("添加" + i + "成功"); } // getMapEntry(map); // getCollectionValues(map); getKeySet(map); } /** * 把一个map对象放到放到entry里,然后根据entry同时得到key和值 * (效率高)entryset只是遍历了第一次,他把key和value都放到了entry中,所以就快. * @param map */ private static void getMapEntry(Map<String, Student> map){ if(!map.isEmpty()){ Set<Map.Entry<String, Student>> entries = map.entrySet(); if(!entries.isEmpty()){ Iterator<Entry<String, Student>> iterator = entries.iterator(); while (iterator.hasNext()) { Map.Entry<java.lang.String, Student> entry = (Map.Entry<String, Student>) iterator.next(); String key = entry.getKey(); Student student = entry.getValue(); String name = student.getName(); String addreess = student.getAddress(); int id = student.getId(); System.out.println("id == " + id + " name == " + name + " address === " + addreess); } } } } /** * 把key放到一个集合里,遍历key值同时根据key得到值 * (效率低,对于keySet其实是遍历了2次,一次是转为iterator,一次就从hashmap中取出key所对于的value。) * @param map */ private static void getKeySet(Map<String, Student> map){ if(!map.isEmpty()){ Set<String> set = map.keySet(); if(!set.isEmpty()){ Iterator<String> iterator = set.iterator(); while (iterator.hasNext()) { String key = (String) iterator.next(); Student student = map.get(key);//根据key获取map的值 String name = student.getName(); String addreess = student.getAddress(); int id = student.getId(); System.out.println("id == " + id + " name == " + name + " address === " + addreess); } } } } /** * 把值放到一个集合力,然后便利集合 * @param map */ private static void getCollectionValues(Map<String, Student> map){ if(!map.isEmpty()){ Collection<Student> collection = map.values(); if(!collection.isEmpty()){ Iterator<Student> iterator = collection.iterator(); while (iterator.hasNext()) { Student student = (Student) iterator.next(); String name = student.getName(); String addreess = student.getAddress(); int id = student.getId(); System.out.println("id == " + id + " name == " + name + " address === " + addreess); } } } } }
package com.xiawenquan.map.demo; public class Student { private String name; private String address; private int id; public Student(String name, String address, int id) { this.name = name; this.address = address; this.id = id; } public Student() { // TODO Auto-generated constructor stub } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public int getId() { return id; } public void setId(int id) { this.id = id; } }
最新技术文章: