android初级进阶
针对一些Android应用层一般不太常用或者注意不到的知识点进行讲解
boy_nihao
coding
展开
-
leetcode:144. Binary Tree Preorder Traversal
转载请注明出处:z_zhaojun的博客 原文地址 题目地址 Binary Tree Preorder TraversalGiven a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3},return [1,2,3].思路:优先添原创 2016-03-19 22:09:45 · 1657 阅读 · 0 评论 -
Andrioid进程保护
这篇博文主要是关于进程保活的应用,通过对网上各种进程保活方式的学习,自己理解后做汇总、优化、简单封装。进程保活,主要就为了加强你写的app在手机上的生存能力,降低被手机干掉的几率。当然,如果想要完全保证app不被杀死,那是不可能的(因为就是你再厉害,也厉害不过手机厂商),所以只能是尽量提高app的存活几率。下面将通过‘AIDL +JobS原创 2017-08-08 15:53:52 · 2216 阅读 · 0 评论 -
leetcode:41. First Missing Positive (Java)
转载请注明出处:z_zhaojun的博客 原文地址 题目地址 First Missing PositiveGiven an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algo原创 2016-03-13 15:28:32 · 1691 阅读 · 1 评论 -
leetcode:268. Missing Number(Java)解答
转载请注明出处:z_zhaojun的博客 原文地址 题目地址 Missing NumberGiven an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.For example,Given nums = [0, 1, 3原创 2016-03-11 22:07:30 · 2825 阅读 · 0 评论 -
leetcode:122. Best Time to Buy and Sell Stock II(java)解答
转载请注明出处:z_zhaojun的博客 原文地址 题目地址 Best Time to Buy and Sell Stock IISay you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum pro原创 2016-03-05 17:43:02 · 1903 阅读 · 0 评论 -
leetcode:121. Best Time to Buy and Sell Stock(Java)解答
转载请注明出处:z_zhaojun的博客 原文地址 题目地址 Best Time to Buy and Sell Stock My Submissions QuestionSay you have an array for which the ith element is the price of a given stock on day i.If you were only permit原创 2016-03-05 17:14:05 · 2407 阅读 · 0 评论 -
leetcode:238. Product of Array Except Self(Java)解答
转载请注明出处:z_zhaojun的博客 原文地址 题目地址 Product of Array Except SelfGiven an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of原创 2016-03-05 14:14:02 · 1793 阅读 · 0 评论 -
ThreadLocal详解
ThreadLocal是什么早在JDK 1.2的版本中就提供java.lang.ThreadLocal,ThreadLocal为解决多线程程序的并发问题提供了一种新的思路。使用这个工具类可以很简洁地编写出优美的多线程程序。ThreadLocal很容易让人望文生义,想当然地认为是一转载 2016-01-16 20:35:53 · 1020 阅读 · 1 评论 -
leetcode:119. Pascal's Triangle II(Java)解答
转载请注明出处:z_zhaojun的博客 原文地址:http://blog.csdn.net/u012975705/题目地址:https://leetcode.com/problems/pascals-triangle-ii/Pascal’s Triangle IIGiven an index k, return the kth row of the Pascal's tri原创 2016-01-10 17:52:58 · 2450 阅读 · 0 评论 -
leetcode:283. Move Zeroes(Java)解答
转载请注明出处:z_zhaojun的博客 原文地址:http://blog.csdn.net/u012975705题目地址:https://leetcode.com/problems/move-zeroes/ Move ZeroesGiven an array nums, write a function to move all 0's to the end of it while原创 2016-01-10 21:05:39 · 2294 阅读 · 1 评论 -
leetcode:142. Linked List Cycle II(Java)解答
转载请注明出处:z_zhaojun的博客 原文地址:http://blog.csdn.net/u012975705 题目地址:https://leetcode.com/problems/linked-list-cycle-ii/Linked List Cycle IIGiven a linked list, return the node where the cycle be原创 2015-12-27 16:36:19 · 2832 阅读 · 1 评论 -
leetcode:82. Remove Duplicates from Sorted List II(Java)解答
转载请注明出处:z_zhaojun的博客 原文地址:http://blog.csdn.net/u012975705 题目地址:https://leetcode.com/problems/reverse-linked-list-ii/Remove Duplicates from Sorted List IIGiven a sorted linked list, delete all原创 2015-12-27 00:18:19 · 2007 阅读 · 1 评论 -
leetcode:92. Reverse Linked List II(Java)解答
转载请注明出处:z_zhaojun的博客 原文地址:http://blog.csdn.net/u012975705 题目地址:https://leetcode.com/problems/reverse-linked-list-ii/Reverse Linked List IIReverse a linked list from position m to n. Do it in-place an原创 2015-12-26 16:14:34 · 2693 阅读 · 0 评论 -
解决在onCreate()过程中获取View的width和Height为0的4种方法
1、监听Draw/Layout事件:ViewTreeObserverViewTreeObserver监听很多不同的界面绘制事件。一般来说OnGlobalLayoutListener就是可以让我们获得到view的width和height的地方.下面onGlobalLayout内的代码会在View完成La转载 2015-12-15 19:15:18 · 1360 阅读 · 1 评论 -
Android 操作系统的内存回收机制
Android APP 的运行环境 Android 是一款基于 Linux 内核,面向移动终端的操作系统。为适应其作为移动平台操作系统的特殊需要,谷歌对其做了特别的设计与优化,使得其进程调度与资源管理与其他平台的 Linux 有明显的区别。主要包含下面几个层次:Application Framework Application Framework 将整个操作系统分隔成两个部分。对转载 2015-12-10 18:04:25 · 3164 阅读 · 1 评论 -
自定义SectionAdapter显示数据
前言之前在项目中需要在一个ScrollView中显示2个不同类型的列表,因为就2个列表,所以偷了下懒:直接使用的2个ListView来显示。写完之后怎么看怎么别扭,今天抽空学习写了个SectionAdapter,mark下。实现效果主要代码pa原创 2015-12-09 16:41:32 · 2653 阅读 · 0 评论 -
java克隆对象clone()的用法和作用
内容摘要若需修改一个对象,同时不想改变调用者的对象,就要制作该对象的一个本地副本。这也是本地副本最常见的一种用途。若决定制作一个本地副本,只需简单地使用clone()方法即可。Clone是“克隆”的意思,即制作完全一模一样的副本。这个方法在基础类Object中定义成“protected”(受保护)模式。但在希望克隆的任何衍生类中,必须将其覆盖为“public”模式。例如,标准库类Vector覆盖了c转载 2015-12-09 10:02:09 · 24550 阅读 · 2 评论 -
判断App整体处于前台还是后台
转载请注明转自:[noyet12的博客](http://blog.csdn.net/u012975705) 博客原址:http://blog.csdn.net/u012975705上篇博客说道,在项目中使用Notification,想要的效果是在app退出前台工作时拉取后台数据,发现新动态则在通知栏提示用户。要达到这个效果,就必须判断当前app是否处于前台工作,下面给出判断方法。 publi原创 2015-11-30 11:26:05 · 4037 阅读 · 8 评论 -
Android——自定义通知栏使用
Android中通知栏的使用,还是刚学Android时玩过,后面一直没机会用到,今天做项目的时候用到了,这里mark下。原创 2015-11-27 17:46:37 · 2436 阅读 · 0 评论 -
Android中防止重复点击的小技巧
PS: 好久没有写过博客了,不经意间看到这篇在我接触Android不久时写的文章,现在看来确实挺粗糙的(有点看不下去了。。),这里写写我刚想到的另一种思路吧原创 2015-11-26 20:45:46 · 7689 阅读 · 3 评论 -
Android WebView页面加载优化
目前webapp越来越多,体验也越来越好,为了能够更好的使用WebView展示出流畅的的页面,可以从以下几点做优化:WebView缓存资源文件本地存储减少耗时操作客户端UI优化可能有人会说了,为什么不做成native的呢,这样就不用那么的麻烦了。如果我需要加载的内容都是静态的,转载 2015-11-25 15:13:48 · 3202 阅读 · 2 评论 -
解决ScrollView或ListView中嵌套ListView引起的冲突
转载请注明:[noyet12的博客](http://blog.csdn.net/u012975705)在ScrollView或ListView等滑动控件中嵌套ListView时,往往会导致ListView显示不完整,只显示一条数据,想使ListView显示完整可以通过重写ListView的onMeasure方法来解决:原创 2015-11-25 11:45:18 · 5262 阅读 · 2 评论 -
Android Looper详解
下面也有多线程的概念,在C/C++中,子线程可以是一个函数, 一般都是一个带有循环的函数,来处理某些数据,优先线程只是一个复杂的运算过程,所以可能不需要while循环,运算完成,函数结束,线程就销毁。对于那 些需要控制的线程,一般我们都是和互斥锁相互关联,从而来控制线程的进转载 2015-11-24 20:26:58 · 3325 阅读 · 2 评论 -
ScrollView拉到尽头时出现阴影的解决方法
/** * *转载请注明:[noyet12的博客](http://blog.csdn.net/u012975705) *博客原址:http://blog.csdn.net/u012975705 * */想要解决使ScrollView拉到尽头时不出现阴影,需要在布局中添加如下代码:原创 2015-11-24 12:07:12 · 3319 阅读 · 0 评论 -
Android 触摸及手势操作GestureDetector
现在的智能手机不敢说百分百的都是触摸屏,也应该是百分之九九以上为触摸屏了,触摸屏为我们操作无键盘、无鼠标的手机系统带来了很多的便利。当用户触摸屏幕时会产生很多的触摸事件,down、up、move等等。View类有个View.OnTouchListener内部接口,通过重写他的onTouch(View v, MotionEvent event)方法,我们可以处理一些touch事件,如下:public转载 2015-11-24 11:08:40 · 1972 阅读 · 0 评论 -
Android中Bitmap和Drawable详解
一、相关概念1、Drawable就是一个可画的对象,其可能是一张位图(BitmapDrawable),也可能是一个图形(ShapeDrawable),还有可能是一个图层(LayerDrawable),我们根据画图的需求,创建相应的可画对象2、Canvas画布,绘图的目的区域,用于绘图3、Bitmap位图,用于图的处理4、Matrix矩阵转载 2015-11-23 15:29:57 · 2196 阅读 · 2 评论 -
Android 绘图机制:canvas初解
Canvas 即“画布”的意思,在Android中用其来进行2D绘画。在使用canvas来进行绘图时,一般都会自定义一个View来重写它的onDraw方法原创 2015-11-23 11:40:16 · 2692 阅读 · 0 评论 -
单例模式的七种写法
转自:http://cantellow.iteye.com/blog/838473第一种(懒汉,线程不安全):public class Singleton { private static Singleton instance; private Singleton (){} public static Singleton getInstance() { if (inst转载 2015-11-20 11:22:39 · 2160 阅读 · 4 评论 -
Service中onStartCommand方法返回值的探索
onStartCommand方法的返回值 有4种:START_STICKY、START_NOT_STICKY、START_REDELIVER_INTENT、START_STICKY_COMPATIBILITY。 下面通过结合demo测试结果来解释每种返回值所代表的意义。原创 2015-11-20 10:55:26 · 5839 阅读 · 1 评论 -
Android的BroadcastReceiver和EventBus区别是什么
转自图灵社区:http://www.ituring.com.cn/article/198897?utm_source=tuicool BroadcastReceiver是什么鬼?在Android中广播分为两个方面:广播发送者和广播接收者,通常情况下,BroadcastReceiver指的就是广播接收者(广播接收器)。 EventBus又是什么鬼呢?EventBus是一个发布 / 订阅的事件总转载 2015-11-19 17:08:17 · 2271 阅读 · 0 评论 -
Java中的Timer和TimerTask在Android中的用法
转自:http://blog.csdn.net/zuolongsnail/article/details/8168689 <html xmlns="http://www.w3.org/1999/xhtml">在开发中我们有时会有这样的需求,即在固定的每隔一段时间执行某一个任务。比如UI上的控件需要随着时间改变,我们可以使用Java为我们提供的计时器的工具类,即Timer和TimerTask。 T转载 2015-11-18 16:37:06 · 1665 阅读 · 1 评论 -
WebView使用大全
转载请注明转自:noyet12的博客 博客原址:http://blog.csdn.net/u012975705简单介绍WebView是Android中能加载显示网页的控件,可以将其视为一个浏览器。在使用WebView之前必须在AndroidManifest.xml文件中添加权限:<uses-permission android:name="android.permission.INTERNET"原创 2015-11-13 10:50:46 · 2421 阅读 · 0 评论 -
Android中实现图片平移、缩放、旋转同步进行
转载请注明转自:[noyet12的博客](http://blog.csdn.net/u012975705)博客原址:http://blog.csdn.net/u012975705/article/details/49797911源码下载地址:(github)https://github.com/noyo/RotateZoomImageView(csdn)http://download.csdn.net/det原创 2015-11-12 13:35:11 · 7185 阅读 · 6 评论 -
Android注解式绑定控件BindView
转载请注明 出处:http://blog.csdn.net/u012975705/article/details/49637401Android注解式绑定控件BindView原创 2015-11-04 14:20:25 · 26990 阅读 · 0 评论 -
定义属于自己的数组适配器
准备弄个自定义的下拉列表框,本来是想用ArrayAdapter来显示数据的,不过最后还是觉得应该学着写个通用的数组适配器代码public abstract class SpinnerAdapter<T> extends BaseAdapter { protected Context mContext; private List<T> mObjects; protected L原创 2015-09-15 18:50:14 · 2377 阅读 · 0 评论 -
使用Android studio分析内存泄露
转自:http://www.jianshu.com/p/c49f778e7acf 使用Android studio分析内存泄露 This post i转载 2015-11-02 15:59:40 · 3343 阅读 · 0 评论 -
自定义圆形图片CircleImageView
效果图具体代码实现自定义的ImageView:CircleImageView.javapackage com.plusub.rentlandapp.view;import android.content.Context;import android.graphics.Bitmap;import android.graphics.Canvas;import android.graphics.dr原创 2015-11-02 11:35:43 · 2057 阅读 · 0 评论 -
类似网购电影票的简易GridView选择器
转载请注明出处:http://blog.csdn.net/u012975705 源码下载: (csdn)http://download.csdn.net/detail/u012975705/9231349 (github)https://github.com/noyo/GridViewSelectPopWin实现效果图废话不多说,先上图片。 实现代码MainActivity.javapa原创 2015-11-01 15:57:20 · 3758 阅读 · 0 评论 -
自定义简易确认取消Dialog
转载请注明:http://blog.csdn.net/u012975705SimpleConfirmDialog.javapublic class SimpleConfirmDialog extends Dialog implements View.OnClickListener { //提示语 private TextView mSlogan; //取消按钮 priv原创 2015-10-31 10:05:10 · 4022 阅读 · 3 评论 -
Android中layout_align****和setPadding方法整合
前言最近在项目中遇到一个问题,要求显示下面的效果。 如图所示,“所属农庄”必须紧挨在“商品名字”后面,但当商品名字过长时必须使得所属农庄显示完整,并且商品名字中显示不全的部分使用省略号,开始一直没弄出来,后面想到用layout_align****,才成功实现其效果。 其他不说,先来来看看layout_align**** 的用法。layout_align**** 介绍layout_align***原创 2015-10-20 21:01:05 · 5026 阅读 · 2 评论