- 博客(12)
- 资源 (1)
- 收藏
- 关注
原创 获取status bar的高度
private int getStatusBarheight() { try { Class clazz = Class.forName("com.android.internal.R$dimen"); Object obj = clazz.newInstance(); Field field = clazz.
2015-12-29 17:13:53 695
原创 使用清华镜像下载Android源码
1. 创建bin路径 macbookpro-2d30:~ xxx$ mkdir bin PATH=~/bin:$PATH2. 从清华镜像下载repo文件 macbookpro-2d30:bin xxx$ git clone git://aosp.tuna.tsinghua.edu.cn/android/git-repo.git 从git-repo文件下降re
2015-12-26 20:07:04 4685
原创 [Binary Search]Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.
2015-12-16 16:32:45 461
原创 ContentProvider启动时机问题简记
今天代码中用到了自定义的ContentProvider,除了在AndroidManifest.xml中的声明外:,应用侧的代码并没有显示启动MyProvider的逻辑。1. 那么ContentProvider是什么时候启动起来的?MyProvider的onCreate方法的执行调用栈可知:MyContentProvider.onCreate() line: 47MyConten
2015-12-15 00:30:10 7673
原创 [DP] Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at
2015-12-14 14:56:34 555
原创 Android之meta-data理解
android:resource="resource specification" android:value="string" />是提供给父组件使用的任意数据类型的补充数据。可以嵌入在如下几种Component组件中: 在每种AndroidManifest的某个组件中申明时,其数量没有限制,最终都是保存在Bundle类型
2015-12-11 16:19:40 700
原创 byte[]和short[]
1. short[] to byte[]ByteBuffer buffer = ByteBuffer.allocate(shortArray.length * 2);buffer.order(ByteOrder.LITTLE_ENDIAN);buffer.asShortBuffer().put(shortArray);byte[] bytes = buffer.array();
2015-12-10 19:13:50 869
原创 [DP] Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the
2015-12-10 14:51:20 926
原创 Android 连续点击back button退出当前Activity的两种实现方法
设定连续两次点击的时间差在2s内为有效。1. 通过辅助标志位和用sendEmptyMessageDelayed方法来进行更新的方式:private static boolean exited = false; mBackButton.setOnClickListener(new View.OnClickListener() { @Override
2015-12-09 19:03:55 3572
原创 Pow(x, n)
Implement pow(x, n).public class Solution { double myPow(double x, int n) { if(n==0) return 1; if(n<0){ n = -n; x = 1/x; } return n%2==0
2015-12-07 15:02:16 413
原创 [DP] Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \
2015-12-07 14:24:43 643
原创 长度为0的数组和 null
长度为0的数组 int[] arr = new int[0],也称为空数组,虽然arr长度为0,但是依然是一个对象null数组,int[] arr = null;arr是一个数组类型的空引用。1. 编写api方法,进行参数校验时,不要漏掉空数组的情况比如下面这个计算递增子序列最大长度的方法,要考虑空数组的情况。public class Solution { public i
2015-12-03 12:59:36 13295
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人