- 博客(73)
- 资源 (2)
- 收藏
- 关注
原创 Android界面相关的类
Window是Activity的界面表达,并作为顶层View被添加到WindowManager中。Window提供了标准的UI显示策略:界面背景、标题区域、默认的事件处理。该抽象类只有一个子类PhoneWindow。WindowManager应用和设备窗口管理器(Window Manager)交互的接口
2015-07-10 18:31:11 844
原创 Activity启动流程、Looper及Handler
android.app.ActivityThread该类中的main方法是Android应用的入口,执行main方法的线程为主线程,主线程默认创建一个Looper对象和Handler,用于处理发送给主线程的Message
2015-07-08 15:39:28 2581
原创 Android异步任务
本文主要探讨Android平台提供的各种异步加载机制,包括它们的适用场景、使用方法等。1. AsynTaskAsynTask适用于最长可以持续几秒钟的短时间的操作,对于长时间的操作,建议使用java.util.concurrent包下的多线程框架。定义一个AsynTask时需要提供以下三个泛型参数的实际类型: Params:被传递给后台线程执行的参数的类型 Progress:后台线程执
2015-06-03 17:04:58 815
原创 Android设计中的尺寸问题
Android把屏幕大小分成四种:small, normal, large, xlarge; 屏幕密度分成:low(ldpi), medium(mdpi), high(hdpi), extra high(xhdpi);各个屏幕密度之间的关系如下: 密度名称 密度的参考值(dpi) 关系 对应的屏幕分辨率 xxxhdpi 640dpi xxhdpi 480d
2015-06-02 17:45:11 990
原创 Android事件处理模型
事件处理是Android编程中非常重要的一个部分,因为Android应用在运行过程中会产生许多各种各样的事件(动作),应用必须为这些动作执行对应的响应代码;将产生的动作和响应联系起来的方式就是事件处理机制。Android平台提供了两种事件处理机制,分别是基于监听的模式和基于回调的模式。1. 基于监听的事件处理模型1.1 组成部分 事件源:事件发生的地方,比如某个按钮、文本框等 事件:事
2015-05-28 22:49:35 952
原创 ART
ART(Andorid Runtime)是Google在新版Android系统中引入的运行时环境;在此之前,Android一直使用Dalvik虚拟机作为java的运行平台。用过Android手机的小伙伴们都知道一个不争的事实,Android手机在流畅度方面显然和苹果不在一个层次上,因此,Android团队在一直在对系统的各个方面进行优化,运行环境就是其优化的一个方面。ART特征 编译提前(
2015-05-28 20:46:30 654
原创 Java内存管理及垃圾回收总结
Java和C++的一个非常重要的区别在于内存管理,JVM把内存管理及垃圾回收接管过来,不需要Java程序员显式的管理对象的生命周期,从而避免了诸如内存溢出及内存泄露等问题;但作为一个Java程序员,深刻理解Java的内存管理及垃圾回收机制,对于理解Java对象的创建过程,有效利用内存,构建高性能Java应用将具备非常重要的意义,因此本文对Java的内存管理机制做了一个详细的介绍。
2014-10-06 20:03:04 1312
原创 [LeetCode] Sort List
LeetCode: https://oj.leetcode.com/problems/sort-list/
2014-09-21 22:01:34 447
原创 [LeetCode] Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it to {1,4
2014-09-21 21:53:23 580
原创 [LeetCode]Longest Valid Parentheses
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()", which
2014-09-21 21:29:22 582
原创 [LeetCode]Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3Return 6.
2014-09-21 18:05:57 429
原创 [LeetCode] Median of Two Sorted Arrays
Median of Two Sorted ArraysThere are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n))LeetC
2014-09-21 17:50:18 478
原创 [LeetCode] Palindrome Partitioning && Palindrome Partitioning II
Palindrome Partitioning Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",
2014-09-21 17:09:17 382
原创 [LeetCode] Word Break && Word Break II
Given a string s and a dictionary of words dict, determine ifs can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict = ["leet",
2014-09-21 16:23:50 441
原创 [LeetCode]Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total number
2014-09-21 15:24:59 399
原创 [LeetCode] String to Integer(atoi)
String to Integer(atoi)Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself wha
2014-09-19 16:10:30 453
原创 [LeetCode] Surrounded Regions
Surrounded RegionsGiven a 2D board containing 'X' and 'O', capture all regions surrounded by'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,
2014-09-19 15:58:59 376
原创 [LeetCode]Merge Intervals && Insert Interval
LeetCode: https://oj.leetcode.com/problems/merge-intervals/
2014-09-19 15:34:29 520
原创 [LeetCode] Reverse Words in a String
Reverse Words in a StringGiven an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".click to show clarification.Clarification
2014-09-14 16:43:23 491
原创 [LeetCode] Word Search
Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically n
2014-09-14 16:03:49 405
原创 [LeetCode] Word Ladder
LeetCode: https://oj.leetcode.com/problems/word-ladder/
2014-09-14 15:44:06 556
原创 Java深度拷贝
基本概念浅拷贝:复制后对象的所有基本类型域的值与原对象相等,所有引用指向的对象和原对象指向的对象相同深拷贝:复制后对象的所有基本类型的值与原对象相等,且他们的引用指向不同的对象,但对象中的基本类型域的值相等,假如其中还包含引用,则指向的对象同样被拷贝了一份,以此类推(即所有引用链上的对象都被拷贝了一份)依赖clone方法的深度拷贝在Java的Object类中有一个clone方法
2014-09-13 22:52:46 1286
原创 [LeetCode]Combinations
LeetCode: https://oj.leetcode.com/problems/combinations/该题采用DFS的方法来解决,和Permutations,N-Queens的解决方式类似:代码如下:public class Solution { public List> combine(int n, int k) { List> comb
2014-09-12 19:50:20 397
原创 [LeetCode]Binary Tree Maximum Path Sum
LeetCode: https://oj.leetcode.com/problems/binary-tree-maximum-path-sum/
2014-09-12 19:40:15 438
原创 [LeetCode] Path Sum && Path Sum II
Path Sum: https://oj.leetcode.com/problems/path-sum/Path Sum II: https://oj.leetcode.com/problems/path-sum-ii/
2014-09-12 18:54:23 497
原创 [LeetCode] Search in Rotated Sorted Array
LeetCode: https://oj.leetcode.com/problems/search-in-rotated-sorted-array/
2014-09-12 16:20:27 408
原创 树的遍历
本文对树的遍历操作做个总结:1. 前序遍历递归实现:public class Solution { public List preorderTraversal(TreeNode root){ List result = new ArrayList(); preOrder(result, root); return result; } private void pr
2014-09-12 15:26:26 366
原创 网络IO总结
网络IO的模式包括同步IO,异步IO,阻塞IO,非阻塞IO;这些IO模式之间的区别和联系是任何一个搞网络编程(Socket编程)的人必须弄清楚的问题,下面我们就来一层层的揭开他们的面纱吧。在Unix网络编程第一卷第六章中讨论了五种IO模型:1. 阻塞IO(Blocking IO)2. 非阻塞IO(Nonblocking IO)3. IO多路复用(IO multiplexing)
2014-09-10 16:55:05 502
原创 递归思想解决经典问题
递归是一个非常经典的算法思想,很多问题都可以采用递归来解决,特别是对于树、字符串这类本身就具有递归性质的数据结构相关的问题,下面就列出几个可以用递归来解决的经典问题:1. 字符串排列问题(不包含相同字符)该问题要求求出字符串的所有排列,我们可以循环遍历整个字符串,将每次循环遇到的字符和第一个位置的字符交换,然后求剩下字符串的所有排列;对于剩下的字符串,重复前面的过程,所以这是个递归的过
2014-09-09 21:05:30 962
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人