- 浏览: 47656 次
- 性别:
- 来自: 西安
最新评论
文章列表
hava a look at the following code you will find that
We assign the mNotesCursor field to a local variable at the start of the method. This is done as an optimization of the Android code. Accessing a local variable is much more efficient than accessing a field in the Dalvik VM, so by doing this ...
下面我们将要实现的功能是是将一个MyObject 对象从CurrrentActivity 中传递到 AimActivity中
要在不同的Activity传递对象,首先这个对象必须实现Serializable 以说明它是可序列化的。
如
public class MyObject implements Serializable { /** * */ priv ...
来自: http://hi.baidu.com/lfcaolibin/blog/item/2ce306ec77cebd4478f055b4.html
Cursor与Adapter结合使用
查询数据库均会把查询的结果包装在一个Cursor的子类对象中返回。Cursor就像是位于结果集之上的一个游标,可以对结果集进行向前、向后或 随机的访问。而Cursor本身是一个接口类,提供了对结果集访问的一些抽象方法,根据功能的不同在其子类有着不同的实现。要控制查询时返回的 Cursor类型,可以自定义一个继承自CursorFactory类通过实现其newCursor()方法来返回需要的Curs ...
Working with Context Menus
Android supports the idea of context menus through an action called a long click.
context menu is represented as a ContextMenu class in theAndroid menu architecture. a context menu is owned by a view, the method to populat ...
A Handler allows you to send and process Message and
Runnable objects associated with a thread's MessageQueue.
Each Handler instance is associated with a single thread and that thread's
message queue. When you create a new Handler, it is bound to the thread /
message queue of the thread t ...
1.、android中R文件消失的处理方式
直接点击android工程,选择android tools 选项,点击Fix Project Properties就会自动生成gen 文件夹下的R文件
2.问题描述: 我打算在我的一个新的project中导入一个 Android library project, 但是一导入的时候就出现了错误,R文件没有了,试了上面的方法后也不行,我发现控制台有如下的输出。
ERROR: Unknown option '--auto-add-overlay'
Android Asset Packaging Tool
我试着百度了一下 ...
java 开发几个设计原则;
1单一职责原则【Single Responsibility Principle】
单一职责原则:应该有且仅有一个原因引起类的变更
那使用了单一职责原则有什么好处呢?类的复杂性降低,实现什么职责都有清晰明确的定义;可读性提高 ...
对于像视频这样的大文件,我们可以把它存放在SDCard。 SDCard是干什么的?你可以把它看作是移动硬盘或U盘。
对其的操作因该注意的地方
1.在AndroidManifest.xml中加入访问SDCard的权限如下:
<!-- 在SDCard中创建与删除文件权限 -->
下面将实现一个序列化对象的例子,也就是将对象保存到文件中,在从文件中读出对象步骤:1确保要保存的对象实现了Serializeable 接口2通过创建一个ObjectOutputStream()对象来打开文件3通过writeObject()将对象写入文件4完成后关闭输入流。
从文件中读取对象1通过一个ObjectInputStream()对象来打开文件2通过调用readObject()来读取对象,并将对像强制转换为读取对象的实际类型3关闭流。
一:定义一个类My.class 作为序列化的对象/** * */package hust.ophoneclub.SerialDemo;
import ...
view animation 的实现
Understanding View AnimationWhen a view is displayed on a presentation surface in Android, it goes through atransformation matrix. In graphics applications, you use transformation matrices totransform a view in some way. The process involves taking the input set of pixelcoordinate ...
java 正则表达式的使用及代码重构(优雅代码实现)案列
实现功能 将 the first item is a hamer,with a cost of $132.99. 分解成单个的单词,数字,标点。
/**The following program It tokenizes a string into its
* textual components: words, numbers,
* or punctuation. Although it is a simple example, it illustrates
* the basic techniques used t ...
本文来源于: 从此学习网 原文: http://www.congci.com/item/android-gaoshou
高效的编写高效的代码
高效快速的编写代码和编写高效率执行的代码很多时候都是对立的死敌,很多时候,你想快速的开发,代码的执行效率往往就会慢下来;你想编写高效的代码,开发速度就会慢下来。
不重复发明轮子和发明新的轮子是高效的编写高效的代码的正确是道路。
关于高效的代码,下面网络的一篇文章,直接转载(不知道是哪位哥们写的)如下:
“现代的手持设备,与其说是电话,更像一台拿在手中的电脑。但是,即使是“最快”的手持设备,其性能也赶不上一台普通的台式电脑。
这就是为什么我 ...
1错误信息要更加的明确化。
下面是在百汇中新建一个文件夹时报的错误,这种错误信息显得就不是很完美,它只是说不允许包含特殊字符,但是却没有告诉我们到底哪些算是特殊字符,然后我们只能一个一个的试,这对用户体验来说是很大的损害。 如果他能提供更具体的错误信息,如哪些是所谓的特殊字符,岂不更好,用户一下子就知道怎么改,而不用自己思考,自己去试了。
下面来看看一个非常棒的错误信息提示
看上面我新建一个文件夹时,里面还有特殊字符,这是Windows给了我很好的错误提示,我一眼就知道是什么地方错了
要做到敏捷开发需要做到以下几点
A不要有重复的代码;
B去掉不该有的注释
1)每一个注释都是很好的改进机会 如我们可以用方法名取代注释
2)一个方法最好单一而优雅的完成一个任务,任务越是单一,重用概率越高,绝不能完成太多的任务
Scale animation: You use this type of animation to make a view smalleror larger either on the x axis or on the y axis. You can also specify thepivot point around which you want the animation to take place.
下面我们将要实现一个scale Animation的小列子
1)在anim文件夹下用xml定义一个scale Animation
<set xmlns:android=" ...