代码改变世界

android开发 九宫格

2016-03-25 09:41 by 宁小哥, 279 阅读, 0 推荐, 收藏, 编辑
摘要:<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com 阅读全文

android开发 集合类之map hashMap

2016-03-21 08:24 by 宁小哥, 4436 阅读, 0 推荐, 收藏, 编辑
摘要:map是个接口 ,hashMap是map的众多实现之一 map类可以理解为Objective - C中的字典 代码: package test;import java.util.HashMap;import java.util.Map;public class Test { public stati 阅读全文

android开发 集合类之set和hashSet

2016-03-18 12:12 by 宁小哥, 5479 阅读, 0 推荐, 收藏, 编辑
摘要:继承关系:Iterator --> collction -->set -->hashSet 需要指出的是set类是个接口 想使用set类 需要运用set类的实现类hashSet set类是集合类,里面存储的对象有别于arrayList,set类不能通过下标的方式直接取到对象,因为set类是无序类 s 阅读全文

android开发 ArrayList用法

2016-03-18 09:49 by 宁小哥, 13071 阅读, 1 推荐, 收藏, 编辑
摘要:想使用ArrayList首先需要import java.util.ArrayList; 实例化: ArrayList<Object> arrayList = new ArrayList<Object>(); 常用方法: ArrayList根类为collection,所以ArrayList可以使用co 阅读全文

android开发 数组

2016-03-18 09:20 by 宁小哥, 1505 阅读, 0 推荐, 收藏, 编辑
摘要:java数组有别于Objective - C中的数组 java中的数组都是可变数组 可以随时改变数组中元素的值 创建数组: int array [] = new int[10]; 实例化一个长度为10的数组 取法:array[0] 二维数组:int array[][] = {{0,1},{2,3}, 阅读全文

android开发 线程同步锁

2016-03-17 17:46 by 宁小哥, 840 阅读, 0 推荐, 收藏, 编辑
摘要:package test;public class MyThread implements Runnable{ public void run() { for(int i = 5000 ; i > 0 ; i--){ synchronized (this) { System.out.println( 阅读全文

android开发 多线程

2016-03-17 16:30 by 宁小哥, 202 阅读, 0 推荐, 收藏, 编辑
摘要:第一种方法: 开线程:创建一个类,继承Thread类。实例化此类,调用此类父类的start();方法 代码: public class FirstThread extends Thread{ @Override public void run() { for(int i = 0; i < 100; 阅读全文

android开发 内部类 匿名内部类

2016-03-17 14:46 by 宁小哥, 1168 阅读, 0 推荐, 收藏, 编辑
摘要:内部类:类中有实现另一个类 内部类可以使用外部类的成员变量 例: package test;public class A { int i; class B{ int j; int funB(){ int c = A.this.i + j; return c; } }} 实例化: package te 阅读全文

android开发 装饰者模式

2016-03-17 11:59 by 宁小哥, 294 阅读, 0 推荐, 收藏, 编辑
摘要:1. package test;interface Dongwu { void eat();} 2. package test;public class Gou implements Dongwu{ public void eat() { // TODO Auto-generated method 阅读全文

android开发 字符流

2016-03-17 10:36 by 宁小哥, 460 阅读, 0 推荐, 收藏, 编辑
摘要:字符流:读写文件时,以字符为基础 字节输入流 :reader抽象类 常用子类:FileReader 用法:int read(char 【】c,int off,int len) 字节输出流:writer抽象类 常用子类:FileWriter 用法:void writer(char 【】 c ,int 阅读全文