来京学习第16天
2015-07-28 18:50
309 查看
明天、后天出去休假,星期五在家休息,星期六和星期天上课,一直到下周五,连续7天要上课。我实际上,不想突然闲死,然后,再累死,入乡随俗吧。。。
2、通过Project Structure 找到Android SDK
3、安装GenymotionShell虚拟电脑
4、通过Oracle VM VirtualBox的管理导入虚拟电脑,开启一个虚拟机
5、在Android Studio创建工程。
6、给Android Studio安装Genymotion插件
1)打开Android Studio,依次【File】-【Settings】
2)在打开的settings界面里找到plugins设置项,点击右侧的“Browser。。”按钮
3)在搜索栏里输入genymotion关键字,可以看到右侧已经搜索到插件,点击install安装。
4)安装后重新启动Android Studio,我们就可以工具栏看到genymotion插件的图标。
5)初次点开需要我们设置一下genymotion的安装目录(C:\program files\Genymobile\Genymotion)。
6)设置好目录,我们再次点击工具栏的图标就可以进行虚拟机的配置和启动了。
今天的学习内容
object的getClass反射
package com.hhl.test20150728; import java.lang.reflect.Field; import java.lang.reflect.Method; public class TestObjectFanshe { public static void main(String[] args) { Student han=new Student(); Class<? extends Student> class1=han.getClass(); Class<? extends Student> class2=Student.class; Field[] f1=class1.getFields();//公共字段 Field[] f2=class1.getDeclaredFields();//所有字段 Method[] m=class2.getDeclaredMethods();//所有方法 Field f3; try { f3 = class1.getDeclaredField("age");//取字段 f3.setAccessible(true);//更改访问权限 f3.setInt(han,20);//设置私有成员的值 f3.setAccessible(false); for(int i=0;i<f2.length;i++){ System.out.println(f2[i].getName()); } System.out.println("年龄:"+han.getAge()); System.out.println("------------------"); for(int i=0;i<m.length;i++){ System.out.print(m[i].getName()+" "); Class[] p=m[i].getParameterTypes();//参数类型取 Class for(int j=0;j<p.length;j++){ System.out.println("参数:"+p[j].getName()); } System.out.println(); } }catch (IllegalArgumentException | IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchFieldException | SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
注解Annotation的应用
package com.hhl.test20150728; public class Student { private int age=20; private String name; private String sex; public int getAge() { return age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public void setAge(int age) { this.age = age; } } package com.hhl.test20150728; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) public @interface MyAnnotation { String name1() default "zhang3"; String sex1(); int age1(); } package com.hhl.test20150728; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) public @interface NumAnnotation { int num1(); } package com.hhl.test20150728; import java.lang.reflect.Field; public class Clazz { @NumAnnotation(num1=101) private int num; @MyAnnotation(age1 = 10, sex1 = "male") private Student z3; @MyAnnotation(age1 = 8, sex1 = "male", name1 = "li4") private Student l4; @MyAnnotation(age1 = 7, sex1 = "female", name1 = "wang5") private Student w5; private Student h6; public Clazz() { zhujie(); } public Student getZ3() { return z3; } public void setZ3(Student z3) { this.z3 = z3; } public Student getL4() { return l4; } public void setL4(Student l4) { this.l4 = l4; } public Student getW5() { return w5; } public void setW5(Student w5) { this.w5 = w5; } public Student getH6() { return h6; } public void setH6(Student h6) { this.h6 = h6; } public void zhujie() { Class<? extends Clazz> cla = Clazz.class; Field[] fs = cla.getDeclaredFields(); for (int i = 0; i < fs.length; i++) { Field f = fs[i]; MyAnnotation mya = f.getAnnotation(MyAnnotation.class); if (mya != null) { f.setAccessible(true); Student st = new Student(); st.setAge(mya.age1()); st.setName(mya.name1()); st.setSex(mya.sex1()); try { f.set(this, st); f.setAccessible(false); }catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); }catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } }else{ NumAnnotation numa=f.getAnnotation(NumAnnotation.class); if(numa!=null){ f.setAccessible(true); System.out.println(numa.num1()); } } } } public int getNum() { return num; } public void setNum(int num) { this.num = num; } } /////////////////////////////////////////// package com.hhl.test20150728; public class TestAnnotation { public static void main(String[] args) { Clazz c=new Clazz(); System.out.println(c.getZ3().getName()); System.out.println(c.getL4().getName()); System.out.println(c.getW5().getName()); //System.out.println(c.getH6().getName()); } }
Android环境的搭建
1、安装Android Studio2、通过Project Structure 找到Android SDK
3、安装GenymotionShell虚拟电脑
4、通过Oracle VM VirtualBox的管理导入虚拟电脑,开启一个虚拟机
5、在Android Studio创建工程。
6、给Android Studio安装Genymotion插件
1)打开Android Studio,依次【File】-【Settings】
2)在打开的settings界面里找到plugins设置项,点击右侧的“Browser。。”按钮
3)在搜索栏里输入genymotion关键字,可以看到右侧已经搜索到插件,点击install安装。
4)安装后重新启动Android Studio,我们就可以工具栏看到genymotion插件的图标。
5)初次点开需要我们设置一下genymotion的安装目录(C:\program files\Genymobile\Genymotion)。
6)设置好目录,我们再次点击工具栏的图标就可以进行虚拟机的配置和启动了。
相关文章推荐
- UIAlertController的用法
- OpenCV中的HOG+SVM物体分类
- 2015 Multi-University Training Contest 3
- 12034 - Race(递推)
- shell基础
- 使用第三方 签章 时碰到的问题
- HDOJ 取石子游戏 1527【威佐夫博奕】
- mongodb
- Acboy needs your help again!
- Java多线程设计模式之线程池模式
- Android开发中使用Service还是Thread
- HDU 2041 超级楼梯
- 深入理解CSS3 Animation 帧动画 ( steps )
- DayDayUP_linuxC学习日记 _利用C实现文件的复制
- python的字符序列处理
- 【HW测试实习】如何初始配置交换机网络使能Telnet
- Elasticsearch-HttpServerModule
- 路由器和交换机
- 解决使用JavaScriptConvert转换对象为Json时,中文和&符号被转码的问题
- jq滚动插件jquery.nicescroll+定位到底部