﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-梦幻之旅-随笔分类-Android</title><link>http://www.blogjava.net/hwpok/category/52956.html</link><description>DEBUG - 天道酬勤</description><language>zh-cn</language><lastBuildDate>Mon, 02 Sep 2013 01:52:56 GMT</lastBuildDate><pubDate>Mon, 02 Sep 2013 01:52:56 GMT</pubDate><ttl>60</ttl><item><title>小米手机  存在  严重 质量问题</title><link>http://www.blogjava.net/hwpok/archive/2013/08/29/403438.html</link><dc:creator>惠万鹏</dc:creator><author>惠万鹏</author><pubDate>Thu, 29 Aug 2013 05:36:00 GMT</pubDate><guid>http://www.blogjava.net/hwpok/archive/2013/08/29/403438.html</guid><wfw:comment>http://www.blogjava.net/hwpok/comments/403438.html</wfw:comment><comments>http://www.blogjava.net/hwpok/archive/2013/08/29/403438.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/hwpok/comments/commentRss/403438.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/hwpok/services/trackbacks/403438.html</trackback:ping><description><![CDATA[冲着小米的"发烧"配置, 满怀欣喜地买了一部小米, 不料买回不到一周, 小米真的"发烧"了!<br />小米手机存在两个严重质量问题:<br /><br />1.电源键开屏老是失灵,症状如下:<br />&nbsp;&nbsp; 手机屏幕自动锁定后,按电源键不能唤醒屏幕, 重复几次也无效.<br />&nbsp;&nbsp; 让手机"休息"二三分钟后, 再按电源键开屏, 能正常开屏.<br /><br />2.对SD等存储卡兼容性极差,症状是提示SD卡未格式化. 解决起来很繁琐,且不能从根本上解决此问题.<br /><br />真心劝告打算购买小米手机的朋友,慎重考虑!<br /><br /><br /><br /><img src ="http://www.blogjava.net/hwpok/aggbug/403438.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/hwpok/" target="_blank">惠万鹏</a> 2013-08-29 13:36 <a href="http://www.blogjava.net/hwpok/archive/2013/08/29/403438.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】创建和使用Android library工程</title><link>http://www.blogjava.net/hwpok/archive/2013/06/02/400062.html</link><dc:creator>惠万鹏</dc:creator><author>惠万鹏</author><pubDate>Sat, 01 Jun 2013 16:29:00 GMT</pubDate><guid>http://www.blogjava.net/hwpok/archive/2013/06/02/400062.html</guid><wfw:comment>http://www.blogjava.net/hwpok/comments/400062.html</wfw:comment><comments>http://www.blogjava.net/hwpok/archive/2013/06/02/400062.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/hwpok/comments/commentRss/400062.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/hwpok/services/trackbacks/400062.html</trackback:ping><description><![CDATA[<span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">创建library供多个工程共享代码、资源是非常常见的需求，网上这种资料非常少，基本上都是讲创建java工程，然后export，这种方式缺点非常多，大家可以自己google一下。</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">本文着重介绍如何创建Android library，并且在工程中使用此library提供的资源，具体步骤如下：</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">1. 创建一个Android工程，命名为MyLib</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">2. 进入工程设置选中Is Library</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">3. 创建另一个Android工程，命名为MyProj</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">4. 进入工程设置，添加MyLib</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">5. 在MyProj的AndroidManifest.xml中加入对library中activity的引用</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">&lt;activity android:name="net.devdiv.mylib.MyLib" /&gt;</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">6. 由于编译后library中的资源和引用它的project资源是合并在一起的，为了避免重名问题，需要对library中资源进行重命名</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">1). 把main.xml改为mylib.xml，同时修改MyLib.java代码setContentView(R.layout.mylib);</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">2). strings.xml修改为</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">&lt;?xml version="1.0" encoding="utf-8"?&gt;</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">&lt;resources&gt;</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">&lt;string name="mylibhello"&gt;String fetched from lib!&lt;/string&gt;</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">&lt;string name="mylib_app_name"&gt;MyLib&lt;/string&gt;</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">&lt;/resources&gt;</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">7. 在MyProj中引用MyLib的资源</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">package net.devdiv.myproj;</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">import android.app.Activity;</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">import android.os.Bundle;</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">import android.widget.TextView;</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><font style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" color="red">import net.devdiv.mylib.*;</font><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">import android.content.Intent;</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">public class MyProj extends Activity {</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">/** Called when the activity is first created. */</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">@Override</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">public void onCreate(Bundle savedInstanceState) {</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">super.onCreate(savedInstanceState);</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">setContentView(R.layout.main);</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">TextView tv = (TextView)findViewById(R.id.myprojtext);</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><font style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" color="red">tv.setText(R.string.mylibhello);</font><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><font style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" color="red">Intent it = new Intent(this, MyLib.class);</font><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">startActivity(it);</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">}</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">}</span><br style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" /><span style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; display: inline !important; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; float: none; letter-spacing: normal; color: rgb(51,51,51); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">原文地址：</span><a style="text-align: left; text-transform: none; background-color: rgb(214,211,214); text-indent: 0px; font: 13px/23px Verdana, Arial, sans-serif, 'Lucida Grande'; white-space: normal; letter-spacing: normal; color: rgb(0,102,255); word-spacing: 0px; text-decoration: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" href="http://www.devdiv.com/thread-36947-1-1.html">http://www.devdiv.com/thread-36947-1-1.html</a><img src ="http://www.blogjava.net/hwpok/aggbug/400062.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/hwpok/" target="_blank">惠万鹏</a> 2013-06-02 00:29 <a href="http://www.blogjava.net/hwpok/archive/2013/06/02/400062.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ListView 点击无效(转)</title><link>http://www.blogjava.net/hwpok/archive/2013/06/01/400054.html</link><dc:creator>惠万鹏</dc:creator><author>惠万鹏</author><pubDate>Sat, 01 Jun 2013 04:36:00 GMT</pubDate><guid>http://www.blogjava.net/hwpok/archive/2013/06/01/400054.html</guid><wfw:comment>http://www.blogjava.net/hwpok/comments/400054.html</wfw:comment><comments>http://www.blogjava.net/hwpok/archive/2013/06/01/400054.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/hwpok/comments/commentRss/400054.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/hwpok/services/trackbacks/400054.html</trackback:ping><description><![CDATA[<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 24px"><span class="Apple-converted-space">&nbsp;</span>&nbsp; &nbsp;记录下自己所犯的错误，在写ListView的点击事件时OnItemClickListener，onItemClick方法没有执行，导致ListView条目点击事件失效，检查发现百度上有很多不同的答案，但究其本质都是ListView的Item抢占焦点或者Item没有获取焦点甚至没有绑定上OnItemClickListener监听事件，而我所犯的错误是在ListView的Item布局中引入了一个Style，在Style中有一项&lt;item name="android:clickable"&gt;true&lt;/item&gt;，正是这一项导致所有Item都要抢占焦点，所以ListView的点击事件失效，在我去掉这一项之后ListView确实正常工作了。需要引以为戒的是，在androidl应用开发中，焦点没有获取或者其他组件抢占焦点的事情经常发生，我们可以在代码中，xml布局中，甚至Style中定义时候抢占焦点，在一般情况下，这个设置并不会造成什么异常，但我需要注意重要的组件在合适的时机必须拿到焦点，否则会产生意想不到的后果，比如我的ListView。一般组件获取焦点可以使用一下方法：</span></p>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 24px"><br /></span></p>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 24px"><span style="background-color: rgb(240,240,240); white-space: pre"></span></span></p>
<div style="text-align: left; text-transform: none; background-color: rgb(231,229,220); text-indent: 0px; margin: 18px 0px; width: 1277px; font: 12px/26px Consolas, 'Courier New', Courier, mono, serif; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); overflow: auto; word-spacing: 0px; padding-top: 1px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="dp-highlighter bg_java">
<div style="padding-left: 45px" class="bar">
<div style="border-left: rgb(108,226,108) 3px solid; padding-bottom: 10px; background-color: rgb(248,248,248); padding-left: 10px; padding-right: 8px; font: 9px Verdana, Geneva, Arial, Helvetica, sans-serif; color: silver; padding-top: 3px" class="tools"><strong>[java]</strong><span class="Apple-converted-space">&nbsp;</span><a style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_plain.gif); border-bottom: medium none; border-left: medium none; padding-bottom: 1px; text-indent: -2000px; margin: 0px 10px 0px 0px; padding-left: 1px; width: 16px; padding-right: 1px; display: inline-block; background-position: 0% 0%; height: 16px; color: rgb(160,160,160); font-size: 9px; border-top: medium none; border-right: medium none; text-decoration: none; padding-top: 1px" class="ViewSource" title="view plain" onclick="dp.sh.Toolbar.Command('ViewSource',this);return false;" href="http://blog.csdn.net/zhufuing/article/details/8677407#">view plain</a><a style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_copy.gif); border-bottom: medium none; border-left: medium none; padding-bottom: 1px; text-indent: -2000px; margin: 0px 10px 0px 0px; padding-left: 1px; width: 16px; padding-right: 1px; display: inline-block; background-position: 0% 0%; height: 16px; color: rgb(160,160,160); font-size: 9px; border-top: medium none; border-right: medium none; text-decoration: none; padding-top: 1px" class="CopyToClipboard" title="copy" onclick="dp.sh.Toolbar.Command('CopyToClipboard',this);return false;" href="http://blog.csdn.net/zhufuing/article/details/8677407#">copy</a> 
<div style="z-index: 99; position: absolute; width: 18px; height: 18px; top: 658px; left: 383px"><embed id="ZeroClipboardMovie_1" height="18" name="ZeroClipboardMovie_1" type="application/x-shockwave-flash" align="center" pluginspage="http://www.macromedia.com/go/getflashplayer" width="18" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" allowscriptaccess="always" allowfullscreen="false" flashvars="id=1&amp;width=18&amp;height=18" wmode="transparent"></div></div></div>
<ol style="border-bottom: medium none; border-left: medium none; padding-bottom: 0px; background-color: rgb(255,255,255); list-style-type: decimal; margin: 0px 0px 1px 45px; padding-left: 0px; padding-right: 0px; color: rgb(92,92,92); border-top: medium none; border-right: medium none; padding-top: 0px" class="dp-j"><li style="list-style-position: outside; border-bottom-style: none; border-left: rgb(108,226,108) 3px solid; padding-bottom: 0px !important; line-height: 18px; border-right-style: none; background-color: rgb(255,255,255); list-style-type: decimal-leading-zero; margin: 0px; padding-left: 10px !important; padding-right: 3px !important; border-top-style: none; padding-top: 0px !important" class="alt"><span style="border-bottom: medium none; border-left: medium none; padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; color: black; border-top: medium none; border-right: medium none; padding-top: 0px"><span style="border-bottom: medium none; border-left: medium none; padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; color: black; border-top: medium none; border-right: medium none; padding-top: 0px">View.setFocusable(</span><span style="border-bottom: medium none; border-left: medium none; padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; color: rgb(0,102,153); border-top: medium none; font-weight: bold; border-right: medium none; padding-top: 0px" class="keyword">true</span><span style="border-bottom: medium none; border-left: medium none; padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; color: black; border-top: medium none; border-right: medium none; padding-top: 0px">),对应xml&nbsp;:&nbsp;android:focusable=</span><span style="border-bottom: medium none; border-left: medium none; padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; color: blue; border-top: medium none; border-right: medium none; padding-top: 0px" class="string">"true"</span><span style="border-bottom: medium none; border-left: medium none; padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; color: black; border-top: medium none; border-right: medium none; padding-top: 0px">.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></li><li style="list-style-position: outside; border-bottom-style: none; border-left: rgb(108,226,108) 3px solid; padding-bottom: 0px !important; line-height: 18px; border-right-style: none; background-color: rgb(248,248,248); list-style-type: decimal-leading-zero; margin: 0px; padding-left: 10px !important; padding-right: 3px !important; border-top-style: none; color: rgb(92,92,92); padding-top: 0px !important"><span style="border-bottom: medium none; border-left: medium none; padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; color: black; border-top: medium none; border-right: medium none; padding-top: 0px">View.setFocusableInTouchMode(<span style="border-bottom: medium none; border-left: medium none; padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; color: rgb(0,102,153); border-top: medium none; font-weight: bold; border-right: medium none; padding-top: 0px" class="keyword">true</span><span style="border-bottom: medium none; border-left: medium none; padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; color: black; border-top: medium none; border-right: medium none; padding-top: 0px">),对应xml&nbsp;:&nbsp;android:focusableInTouchMode=</span><span style="border-bottom: medium none; border-left: medium none; padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; color: blue; border-top: medium none; border-right: medium none; padding-top: 0px" class="string">"true"</span><span style="border-bottom: medium none; border-left: medium none; padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; color: black; border-top: medium none; border-right: medium none; padding-top: 0px">.&nbsp;&nbsp;&nbsp;</span></span></li></ol></div><span style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/25px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"></span><span style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; display: inline !important; font: 14px/26px Arial; white-space: normal; float: none; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"></span>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"></p>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="line-height: 25px"><span style="font-family: 'Microsoft YaHei'; font-size: 24px">注意：这两个属性要同时使用。</span></span></p><span style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 24px/26px 'Microsoft YaHei'; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">两者的意思是让组件可以获得焦点。不过有些区别，前者执行false条件后，在执行true，还是不能获取焦点。后者执行上述过程，还是能获取焦点。&nbsp;<br style="line-height: 25px" /><span style="line-height: 25px">当你加入上述代码后，在创建activity时，调用对应view的requestFocus()，（<span style="line-height: 25px">requestFocus()需要在setContentView之后执行</span>）这样就可以获得焦点了。当editText失去焦点了，也就不会有软键盘了</span></span><br style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" />
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 24px"><span style="line-height: 25px"><br /></span></span></p>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 24px"><span style="line-height: 25px">但针对ListView还可以使用<a style="line-height: 25px; color: rgb(202,0,0); font-weight: bold; text-decoration: none" id="cb_post_title_url" class="postTitle2" href="http://www.cnblogs.com/eyu8874521/archive/2012/10/17/2727882.html"><span style="color: rgb(0,0,0)">android:descendantFocusability</span></a>属性，</span><span style="line-height: 25px">下面我们来看一下</span><a style="line-height: 25px; color: rgb(202,0,0); font-weight: bold; text-decoration: none" id="cb_post_title_url" class="postTitle2" href="http://www.cnblogs.com/eyu8874521/archive/2012/10/17/2727882.html"><span style="color: rgb(0,0,0)">android:descendantFocusability用法简析</span></a></span></p>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 24px">以下摘自：</span><span style="font-size: 18px">http://www.cnblogs.com/eyu8874521/archive/2012/10/17/2727882.html</span><a style="color: rgb(202,0,0); text-decoration: none" href="http://www.cnblogs.com/eyu8874521/archive/2012/10/17/2727882.html"><span style="font-family: 'Microsoft YaHei'; font-size: 24px"></span></a><span style="font-family: 'Microsoft YaHei'; font-size: 24px"></span></p>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"></p>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="line-height: 19px; font-family: 'Microsoft YaHei'; font-size: 24px">&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="font-size: 24px"><span style="font-family: 'Microsoft YaHei'">开发中很常见的一个问题，项目中的listview不仅仅是简单的文字，常常需要自己定义listview，自己的Adapter去继承BaseAdapter，在adapter中按照需求进行编写，问题就出现了，可能会发生点击每一个item的时候没有反应，无法获取的焦点。原因多半是由于在你自己定义的Item中存在诸如ImageButton，Button，CheckBox等子控件(也可以说是Button或者Checkable的子类控件)，此时这些子控件会将焦点获取到，所以常常当点击item时变化的是子控件，item本身的点击没有响应。</span></span></p>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="line-height: 19px; font-family: 'Microsoft YaHei'; font-size: 24px">这时候就可以使用descendantFocusability来解决啦，API描述如下：</span></p>
<h4 style="text-align: left; padding-bottom: 0px; line-height: 19px; text-transform: none; background-color: rgb(255,255,255); font-variant: normal; font-style: normal; text-indent: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); font-size: 14px; word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="jd-details-title"><span style="font-family: 'Microsoft YaHei'; font-size: 24px">android:descendantFocusability</span></h4>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-size: 24px">Defines the relationship between the ViewGroup and its descendants when looking for a View to take focus.</span></p>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-size: 24px">Must be one of the following constant values.</span></p>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"></p>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/19px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 24px">该属性是当一个为view获取焦点时，定义viewGroup和其子控件两者之间的关系。</span></p>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/19px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 24px">属性的值有三种：</span></p>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/19px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 24px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; beforeDescendants：viewgroup会优先其子类控件而获取到焦点</span></p>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/19px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 24px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; afterDescendants：viewgroup只有当其子类控件不需要获取焦点时才获取焦点</span></p>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/19px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-family: 'Microsoft YaHei'; font-size: 24px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; blocksDescendants：viewgroup会覆盖子类控件而直接获得焦点</span></p>
<p style="text-align: left; padding-bottom: 0px; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; margin: 10px auto; padding-left: 0px; padding-right: 0px; font: 14px/26px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; padding-top: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-size: 24px"><span style="font-family: 'Microsoft YaHei'">通常我们用到的是第三种，即在Item布局的根布局加上android:descendantFocusability=&#8221;blocksDescendants&#8221;的属性就好了，至此listview点击的灵异事件告一段落。心得：遇到不会不懂的地方除了网上查询资料之外，也可以多多去尝试每种属性的作用，多阅读官方文档(我始终觉得还是读原文的比翻译的理解的会更好)</span></span></p><img src ="http://www.blogjava.net/hwpok/aggbug/400054.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/hwpok/" target="_blank">惠万鹏</a> 2013-06-01 12:36 <a href="http://www.blogjava.net/hwpok/archive/2013/06/01/400054.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ListView 的优化</title><link>http://www.blogjava.net/hwpok/archive/2013/05/31/400042.html</link><dc:creator>惠万鹏</dc:creator><author>惠万鹏</author><pubDate>Fri, 31 May 2013 14:17:00 GMT</pubDate><guid>http://www.blogjava.net/hwpok/archive/2013/05/31/400042.html</guid><wfw:comment>http://www.blogjava.net/hwpok/comments/400042.html</wfw:comment><comments>http://www.blogjava.net/hwpok/archive/2013/05/31/400042.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/hwpok/comments/commentRss/400042.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/hwpok/services/trackbacks/400042.html</trackback:ping><description><![CDATA[方案1:
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" /><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;View&nbsp;getView(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;position,&nbsp;View&nbsp;convertView,&nbsp;ViewGroup&nbsp;parent)<br /><img id="Codehighlighter1_70_333_Open_Image" onclick="this.style.display='none'; Codehighlighter1_70_333_Open_Text.style.display='none'; Codehighlighter1_70_333_Closed_Image.style.display='inline'; Codehighlighter1_70_333_Closed_Text.style.display='inline';" align="top" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_70_333_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_70_333_Closed_Text.style.display='none'; Codehighlighter1_70_333_Open_Image.style.display='inline'; Codehighlighter1_70_333_Open_Text.style.display='inline';" align="top" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_70_333_Closed_Text"><img src="http://www.blogjava.net/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_70_333_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;View&nbsp;item&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;mInflater.inflate(R.layout.list_item_icon_text,&nbsp;</span><span style="color: #0000ff">null</span><span style="color: #000000">);<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;((TextView)&nbsp;item.findViewById(R.id.text)).setText(DATA[position]);<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;((ImageView)&nbsp;item.findViewById(R.id.icon)).setImageBitmap((position&nbsp;</span><span style="color: #000000">&amp;</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">)&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">?</span><span style="color: #000000">&nbsp;mIcon1&nbsp;:&nbsp;mIcon2);<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;item;<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span></div><br />方案2:<br />
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" /><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;View&nbsp;getView(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;position,&nbsp;View&nbsp;convertView,&nbsp;ViewGroup&nbsp;parent)&nbsp;<br /><img id="Codehighlighter1_71_382_Open_Image" onclick="this.style.display='none'; Codehighlighter1_71_382_Open_Text.style.display='none'; Codehighlighter1_71_382_Closed_Image.style.display='inline'; Codehighlighter1_71_382_Closed_Text.style.display='inline';" align="top" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_71_382_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_71_382_Closed_Text.style.display='none'; Codehighlighter1_71_382_Open_Image.style.display='inline'; Codehighlighter1_71_382_Open_Text.style.display='inline';" align="top" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_71_382_Closed_Text"><img src="http://www.blogjava.net/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_71_382_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(convertView&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">null</span><span style="color: #000000">)&nbsp;<br /><img id="Codehighlighter1_107_175_Open_Image" onclick="this.style.display='none'; Codehighlighter1_107_175_Open_Text.style.display='none'; Codehighlighter1_107_175_Closed_Image.style.display='inline'; Codehighlighter1_107_175_Closed_Text.style.display='inline';" align="top" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_107_175_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_107_175_Closed_Text.style.display='none'; Codehighlighter1_107_175_Open_Image.style.display='inline'; Codehighlighter1_107_175_Open_Text.style.display='inline';" align="top" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_107_175_Closed_Text"><img src="http://www.blogjava.net/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_107_175_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;convertView&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;mInflater.inflate(R.layout.item,&nbsp;</span><span style="color: #0000ff">null</span><span style="color: #000000">);<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;((TextView)&nbsp;convertView.findViewById(R.id.text)).setText(DATA[position]);<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />　((ImageView)&nbsp;convertView.findViewById(R.id.icon)).setImageBitmap((position&nbsp;</span><span style="color: #000000">&amp;</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">)&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">?</span><span style="color: #000000">&nbsp;mIcon1&nbsp;:&nbsp;mIcon2);<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />　</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;convertView;<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span></div><br />方案3:<br />
<div style="border-bottom: #cccccc 1px solid; border-left: #cccccc 1px solid; padding-bottom: 4px; background-color: #eeeeee; padding-left: 4px; width: 98%; padding-right: 5px; font-size: 13px; word-break: break-all; border-top: #cccccc 1px solid; border-right: #cccccc 1px solid; padding-top: 4px"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/None.gif"  alt="" /><span style="color: #0000ff">class</span><span style="color: #000000">&nbsp;ChatListAdapter&nbsp;</span><span style="color: #0000ff">extends</span><span style="color: #000000">&nbsp;BaseAdapter<br /><img id="Codehighlighter1_42_786_Open_Image" onclick="this.style.display='none'; Codehighlighter1_42_786_Open_Text.style.display='none'; Codehighlighter1_42_786_Closed_Image.style.display='inline'; Codehighlighter1_42_786_Closed_Text.style.display='inline';" align="top" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif"><img style="display: none" id="Codehighlighter1_42_786_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_42_786_Closed_Text.style.display='none'; Codehighlighter1_42_786_Open_Image.style.display='inline'; Codehighlighter1_42_786_Open_Text.style.display='inline';" align="top" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif"></span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_42_786_Closed_Text"><img src="http://www.blogjava.net/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_42_786_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />　</span><span style="color: #0000ff">static</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">class</span><span style="color: #000000">&nbsp;ViewHolder&nbsp;<br /><img id="Codehighlighter1_74_115_Open_Image" onclick="this.style.display='none'; Codehighlighter1_74_115_Open_Text.style.display='none'; Codehighlighter1_74_115_Closed_Image.style.display='inline'; Codehighlighter1_74_115_Closed_Text.style.display='inline';" align="top" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_74_115_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_74_115_Closed_Text.style.display='none'; Codehighlighter1_74_115_Open_Image.style.display='inline'; Codehighlighter1_74_115_Open_Text.style.display='inline';" align="top" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_74_115_Closed_Text"><img src="http://www.blogjava.net/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_74_115_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />　　TextView&nbsp;text;<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />　　ImageView&nbsp;icon;<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" /><br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;View&nbsp;getView(</span><span style="color: #0000ff">int</span><span style="color: #000000">&nbsp;position,&nbsp;View&nbsp;convertView,&nbsp;ViewGroup&nbsp;parent)&nbsp;<br /><img id="Codehighlighter1_197_784_Open_Image" onclick="this.style.display='none'; Codehighlighter1_197_784_Open_Text.style.display='none'; Codehighlighter1_197_784_Closed_Image.style.display='inline'; Codehighlighter1_197_784_Closed_Text.style.display='inline';" align="top" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_197_784_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_197_784_Closed_Text.style.display='none'; Codehighlighter1_197_784_Open_Image.style.display='inline'; Codehighlighter1_197_784_Open_Text.style.display='inline';" align="top" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_197_784_Closed_Text"><img src="http://www.blogjava.net/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_197_784_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;　ViewHolder&nbsp;holder;<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;　</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(convertView&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">null</span><span style="color: #000000">)&nbsp;<br /><img id="Codehighlighter1_262_554_Open_Image" onclick="this.style.display='none'; Codehighlighter1_262_554_Open_Text.style.display='none'; Codehighlighter1_262_554_Closed_Image.style.display='inline'; Codehighlighter1_262_554_Closed_Text.style.display='inline';" align="top" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_262_554_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_262_554_Closed_Text.style.display='none'; Codehighlighter1_262_554_Open_Image.style.display='inline'; Codehighlighter1_262_554_Open_Text.style.display='inline';" align="top" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_262_554_Closed_Text"><img src="http://www.blogjava.net/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_262_554_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;　　convertView&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;mInflater.inflate(R.layout.list_item_icon_text,&nbsp;</span><span style="color: #0000ff">null</span><span style="color: #000000">);<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;　　holder&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">new</span><span style="color: #000000">&nbsp;ViewHolder();<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;　　holder.text&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(TextView)&nbsp;convertView.findViewById(R.id.text);<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;　　holder.icon&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(ImageView)&nbsp;convertView.findViewById(R.id.icon);<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;convertView.setTag(holder);<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;　}</span></span><span style="color: #000000">&nbsp;<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">else</span><span style="color: #000000">&nbsp;<br /><img id="Codehighlighter1_579_636_Open_Image" onclick="this.style.display='none'; Codehighlighter1_579_636_Open_Text.style.display='none'; Codehighlighter1_579_636_Closed_Image.style.display='inline'; Codehighlighter1_579_636_Closed_Text.style.display='inline';" align="top" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="display: none" id="Codehighlighter1_579_636_Closed_Image" onclick="this.style.display='none'; Codehighlighter1_579_636_Closed_Text.style.display='none'; Codehighlighter1_579_636_Open_Image.style.display='inline'; Codehighlighter1_579_636_Open_Text.style.display='inline';" align="top" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="border-bottom: #808080 1px solid; border-left: #808080 1px solid; background-color: #ffffff; display: none; border-top: #808080 1px solid; border-right: #808080 1px solid" id="Codehighlighter1_579_636_Closed_Text"><img src="http://www.blogjava.net/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_579_636_Open_Text"><span style="color: #000000">{<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;　　holder&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(ViewHolder)&nbsp;convertView.getTag();<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;　}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;holder.text.setText(DATA[position]);<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;　holder.icon.setImageBitmap((position&nbsp;</span><span style="color: #000000">&amp;</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">)&nbsp;</span><span style="color: #000000">==</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">1</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">?</span><span style="color: #000000">&nbsp;mIcon1&nbsp;:&nbsp;mIcon2);<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;　</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;convertView;<br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="color: #000000"><br /><img align="top" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif"  alt="" />}</span></span></div><br /><img src ="http://www.blogjava.net/hwpok/aggbug/400042.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/hwpok/" target="_blank">惠万鹏</a> 2013-05-31 22:17 <a href="http://www.blogjava.net/hwpok/archive/2013/05/31/400042.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Failed to install *.apk on device 'emulator-5554': timeout</title><link>http://www.blogjava.net/hwpok/archive/2013/05/30/399936.html</link><dc:creator>惠万鹏</dc:creator><author>惠万鹏</author><pubDate>Wed, 29 May 2013 16:02:00 GMT</pubDate><guid>http://www.blogjava.net/hwpok/archive/2013/05/30/399936.html</guid><wfw:comment>http://www.blogjava.net/hwpok/comments/399936.html</wfw:comment><comments>http://www.blogjava.net/hwpok/archive/2013/05/30/399936.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/hwpok/comments/commentRss/399936.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/hwpok/services/trackbacks/399936.html</trackback:ping><description><![CDATA[<table style="text-align: left; text-transform: none; background-color: rgb(255,255,255); text-indent: 0px; width: 898px; font: 14px/25px Arial; white-space: normal; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" border="0">
<tbody>
<tr>
<td style="font-size: 1em">
<div class="cnt">
<p style="padding-bottom: 0px; line-height: normal; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: Arial; padding-top: 0px"><strong style="font-weight: bold">错误提示：</strong></p>
<p style="padding-bottom: 0px; line-height: normal; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: Arial; padding-top: 0px"><strong style="font-weight: bold"><span style="color: rgb(31,153,153)">Failed to install helloworld.apk on device 'emulator-5554': timeout</span></strong></p>
<p style="padding-bottom: 0px; line-height: normal; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: Arial; padding-top: 0px"><strong style="font-weight: bold"><span style="color: rgb(31,153,153)">或者</span></strong></p>
<p style="padding-bottom: 0px; line-height: normal; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: Arial; padding-top: 0px"><strong style="font-weight: bold"><span style="color: rgb(31,153,153)">the user data image is used</span></strong></p>
<p style="padding-bottom: 0px; line-height: normal; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: Arial; padding-top: 0px">&nbsp;</p>
<p style="padding-bottom: 0px; line-height: normal; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: Arial; padding-top: 0px"><strong style="font-weight: bold">原因：</strong></p>
<p style="padding-bottom: 0px; line-height: normal; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: Arial; padding-top: 0px"><strong style="font-weight: bold"><span style="color: rgb(31,153,153)">由于模拟器已经开启而没有关闭或者非法关闭引起的。</span></strong></p>
<p style="padding-bottom: 0px; line-height: normal; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: Arial; padding-top: 0px"><strong style="font-weight: bold">解决方法：</strong></p>
<p style="padding-bottom: 0px; line-height: normal; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: Arial; padding-top: 0px"><strong style="font-weight: bold"><span style="color: rgb(255,0,0)">删除 C:\Documents and Settings\Administrator\.android\avd\对应版本.avd</span><br /><span style="color: rgb(255,0,0)">下所有以.lock结尾的文件夹。</span></strong></p>
<p style="padding-bottom: 0px; line-height: normal; margin: 0px; padding-left: 0px; padding-right: 0px; font-family: Arial; padding-top: 0px">&nbsp;</p></div></td></tr></tbody></table><img src ="http://www.blogjava.net/hwpok/aggbug/399936.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/hwpok/" target="_blank">惠万鹏</a> 2013-05-30 00:02 <a href="http://www.blogjava.net/hwpok/archive/2013/05/30/399936.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>android布局</title><link>http://www.blogjava.net/hwpok/archive/2013/04/22/398232.html</link><dc:creator>惠万鹏</dc:creator><author>惠万鹏</author><pubDate>Mon, 22 Apr 2013 13:07:00 GMT</pubDate><guid>http://www.blogjava.net/hwpok/archive/2013/04/22/398232.html</guid><wfw:comment>http://www.blogjava.net/hwpok/comments/398232.html</wfw:comment><comments>http://www.blogjava.net/hwpok/archive/2013/04/22/398232.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/hwpok/comments/commentRss/398232.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/hwpok/services/trackbacks/398232.html</trackback:ping><description><![CDATA[<span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">LinearLayout&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">　　线性布局，这个东西，从外框上可以理解为一个div，他首先是一个一个从上往下罗列在屏幕上。每一个LinearLayout里面又可分为垂直布局(android:orientation="vertical")和水平布局(android:orientation="horizontal" )。当垂直布局时，每一行就只有一个元素，多个元素依次垂直往下;水平布局时，只有一行，每一个元素依次向右排列。&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">　　linearLayout中有一个重要的属性 android:layout_weight="1"，这个weight在垂直布局时，代表行距;水平的时候代表列宽;weight值越大就越大。&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">RelativeLayout&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">用到的一些重要的属性：&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; 第一类:属性值为true或false&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_centerHrizontal&nbsp; 水平居中&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp;&nbsp; android:layout_centerVertical&nbsp;&nbsp; 垂直居中&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_centerInparent&nbsp;&nbsp;&nbsp; 相对于父元素完全居中&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_alignParentBottom 贴紧父元素的下边缘&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_alignParentLeft&nbsp;&nbsp; 贴紧父元素的左边缘&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_alignParentRight&nbsp; 贴紧父元素的右边缘&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_alignParentTop&nbsp;&nbsp;&nbsp; 贴紧父元素的上边缘&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_alignWithParentIfMissing&nbsp; 如果对应的兄弟元素找不到的话就以父元素做参照物&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; 第二类：属性值必须为id的引用名&#8220;@id/id-name&#8221;&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_below&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在某元素的下方&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_above&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在某元素的的上方&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_toLeftOf&nbsp;&nbsp; 在某元素的左边&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_toRightOf&nbsp; 在某元素的右边&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_alignTop&nbsp;&nbsp; 本元素的上边缘和某元素的的上边缘对齐&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_alignLeft&nbsp; 本元素的左边缘和某元素的的左边缘对齐&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_alignBottom 本元素的下边缘和某元素的的下边缘对齐&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_alignRight&nbsp; 本元素的右边缘和某元素的的右边缘对齐&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; 第三类：属性值为具体的像素值，如30dip，40px&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_marginBottom&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 离某元素底边缘的距离&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_marginLeft&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 离某元素左边缘的距离&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_marginRight&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 离某元素右边缘的距离&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">&nbsp;&nbsp;&nbsp; android:layout_marginTop&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 离某元素上边缘的距离&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">EditText的android:hint&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">设置EditText为空时输入框内的提示信息。&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">android:gravity　&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">android:gravity属性是对该view 内容的限定．比如一个button 上面的text.&nbsp; 你可以设置该text 在view的靠左，靠右等位置．以button为例，android:gravity="right"则button上面的文字靠右&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">android:layout_gravity&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">android:layout_gravity是用来设置该view相对与起父view 的位置．比如一个button 在linearlayout里，你想把该button放在靠左、靠右等位置就可以通过该属性设置．以button为例，android:layout_gravity="right"则button靠右</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">android:layout_alignParentRight&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">使当前控件的右端和父控件的右端对齐。这里属性值只能为true或false，默认false。&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">android:scaleType：&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">android:scaleType是控制图片如何resized/moved来匹对ImageView的size。ImageView.ScaleType / android:scaleType值的意义区别：&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">CENTER /center&nbsp; 按图片的原来size居中显示，当图片长/宽超过View的长/宽，则截取图片的居中部分显示&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">CENTER_CROP / centerCrop&nbsp; 按比例扩大图片的size居中显示，使得图片长(宽)等于或大于View的长(宽)&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">CENTER_INSIDE / centerInside&nbsp; 将图片的内容完整居中显示，通过按比例缩小或原来的size使得图片长/宽等于或小于View的长/宽&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">FIT_CENTER / fitCenter&nbsp; 把图片按比例扩大/缩小到View的宽度，居中显示&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">FIT_END / fitEnd&nbsp;&nbsp; 把图片按比例扩大/缩小到View的宽度，显示在View的下部分位置&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">FIT_START / fitStart&nbsp; 把图片按比例扩大/缩小到View的宽度，显示在View的上部分位置&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">FIT_XY / fitXY&nbsp; 把图片 不按比例 扩大/缩小到View的大小显示&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">MATRIX / matrix 用矩阵来绘制，动态缩小放大图片来显示。&nbsp;</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;" /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25.1875px; background-color: #ffffff;">** 要注意一点，Drawable文件夹里面的图片命名是不能大写的。</span><img src ="http://www.blogjava.net/hwpok/aggbug/398232.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/hwpok/" target="_blank">惠万鹏</a> 2013-04-22 21:07 <a href="http://www.blogjava.net/hwpok/archive/2013/04/22/398232.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>dip，dp，px，pt，sp 的区别</title><link>http://www.blogjava.net/hwpok/archive/2013/04/20/398147.html</link><dc:creator>惠万鹏</dc:creator><author>惠万鹏</author><pubDate>Sat, 20 Apr 2013 15:34:00 GMT</pubDate><guid>http://www.blogjava.net/hwpok/archive/2013/04/20/398147.html</guid><wfw:comment>http://www.blogjava.net/hwpok/comments/398147.html</wfw:comment><comments>http://www.blogjava.net/hwpok/archive/2013/04/20/398147.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/hwpok/comments/commentRss/398147.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/hwpok/services/trackbacks/398147.html</trackback:ping><description><![CDATA[<span style="box-sizing: border-box; color: #4b4b4b; font-size: 13px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; background-color: #ffffff;">dip: device independent pixels(设备独立像素)。不同设备有不同的显示效果，这个和设备硬件有关，一般我们为了支持WVGA、HVGA和QVGA 推荐使用这个，不依赖像素。&nbsp;<br style="box-sizing: border-box;" /><br style="box-sizing: border-box;" /></span><span style="box-sizing: border-box; color: #4b4b4b; font-size: 13px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; background-color: #ffffff;">dp:（与密度无关的像素）一种基于屏幕密度的抽象单位。在每英寸160点的显示器上，1dp = 1px。&nbsp;<br style="box-sizing: border-box;" /></span><span style="box-sizing: border-box; color: #4b4b4b; font-size: 13px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; background-color: #ffffff;"><br style="box-sizing: border-box;" /></span><span style="box-sizing: border-box; color: #4b4b4b; font-size: 13px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; background-color: #ffffff;">px:&nbsp;pixels(像素). 不同设备显示效果相同，一般我们HVGA代表320x480像素，这个用的比较多。&nbsp;<br style="box-sizing: border-box;" /></span><span style="box-sizing: border-box; color: #4b4b4b; font-size: 13px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; background-color: #ffffff;"><br style="box-sizing: border-box;" />pt: point(磅)，是一个标准的长度单位，1pt＝1/72英寸，用于印刷业，非常简单易用；&nbsp;<br style="box-sizing: border-box;" /><br style="box-sizing: border-box;" />sp: scaled pixels(放大像素). 主要用于字体显示best for textsize。&nbsp;</span><img src ="http://www.blogjava.net/hwpok/aggbug/398147.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/hwpok/" target="_blank">惠万鹏</a> 2013-04-20 23:34 <a href="http://www.blogjava.net/hwpok/archive/2013/04/20/398147.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android屏幕分辨率详解（VGA、HVGA、QVGA、WVGA、WQVGA）</title><link>http://www.blogjava.net/hwpok/archive/2013/04/20/398146.html</link><dc:creator>惠万鹏</dc:creator><author>惠万鹏</author><pubDate>Sat, 20 Apr 2013 15:33:00 GMT</pubDate><guid>http://www.blogjava.net/hwpok/archive/2013/04/20/398146.html</guid><wfw:comment>http://www.blogjava.net/hwpok/comments/398146.html</wfw:comment><comments>http://www.blogjava.net/hwpok/archive/2013/04/20/398146.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/hwpok/comments/commentRss/398146.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/hwpok/services/trackbacks/398146.html</trackback:ping><description><![CDATA[<div id="blog_content" style="line-height: 1.8em; font-family: Helvetica, Tahoma, Arial, sans-serif;">这些术语都是指屏幕的分辨率。&nbsp;<br />VGA：Video Graphics Array，即：显示绘图矩阵，相当于640&#215;480 像素；&nbsp;<br />HVGA：Half-size VGA；即：VGA的一半，分辨率为480&#215;320；&nbsp;<br />QVGA：Quarter VGA；即：VGA的四分之一，分辨率为320&#215;240；&nbsp;<br />WVGA：Wide Video Graphics Array；即：扩大的VGA，分辨率为800&#215;480像素；&nbsp;<br />WQVGA：Wide Quarter VGA；即：扩大的QVGA，分辨率比QVGA高，比VGA低，一般是：400&#215;240，480&#215;272；&nbsp;<br /><br /><br />发展历程不一样，wm的手机一开始作为商务机，分辨率就是320*240，后边提高到640*480，再到后来的800*480。HVGA没有作为wm手机的重点，或者说基本忽略了在这个分辨率级别。&nbsp;<br />再谈谈android，我个人认为安卓是效仿iphone的设计思路。&nbsp;<br />1，HVGA基本上属于性价比比较好的方案。分辨率适中，不像320*240的颗粒感那样严重。因为如果提高分辨率就要提高机器的图像处理组件，也就是对硬件的要求相应提高，价格自然是不低。&nbsp;<br />2，谷歌手机一开始推广就是用这个分辨率，例如G1，G2等都是采用HVGA的分辨率。&nbsp;<br />3，现在android的软件基本上都会自动适应HVGA（还包含别的，例如VGA,WVGA等，这个就要看软件作者的了）</div><div id="bottoms" style="font-family: Helvetica, Tahoma, Arial, sans-serif; font-size: 12px; line-height: 18px;"></div><img src ="http://www.blogjava.net/hwpok/aggbug/398146.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/hwpok/" target="_blank">惠万鹏</a> 2013-04-20 23:33 <a href="http://www.blogjava.net/hwpok/archive/2013/04/20/398146.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title> 两分钟彻底让你明白Android Activity生命周期(图文)!</title><link>http://www.blogjava.net/hwpok/archive/2013/04/20/398122.html</link><dc:creator>惠万鹏</dc:creator><author>惠万鹏</author><pubDate>Sat, 20 Apr 2013 05:41:00 GMT</pubDate><guid>http://www.blogjava.net/hwpok/archive/2013/04/20/398122.html</guid><wfw:comment>http://www.blogjava.net/hwpok/comments/398122.html</wfw:comment><comments>http://www.blogjava.net/hwpok/archive/2013/04/20/398122.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/hwpok/comments/commentRss/398122.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/hwpok/services/trackbacks/398122.html</trackback:ping><description><![CDATA[<p style="color: #333333; font-family: Arial; line-height: 26px;">大家好，今天给大家详解一下Android中Activity的生命周期，我在前面也曾经讲过这方面的内容，但是像网上大多数文章一样，基本都是翻译Android API，过于笼统，相信大家看了，会有一点点的帮助 ，但是还不能完全吃透，所以我今天特意在重新总结一下.</p><p style="color: #333333; font-family: Arial; line-height: 26px;">首先看一下Android api中所提供的Activity生命周期图(不明白的，可以看完整篇文章，在回头看一下这个图，你会明白的):</p><p style="color: #333333; font-family: Arial; line-height: 26px;"><img src="http://hi.csdn.net/attachment/201007/28/0_12803210018q71.gif" alt="" style="border: none;" /></p><p style="color: #333333; font-family: Arial; line-height: 26px;">&nbsp;</p><p style="color: #333333; font-family: Arial; line-height: 26px;">Activity其实是继承了ApplicationContext这个类，我们可以重写以下方法，如下代码:</p><p style="color: #333333; font-family: Arial; line-height: 26px;"></p><div bg_java"="" style="width: 687.0499877929688px;"><div><div><strong>[java]</strong>&nbsp;<a href="http://blog.csdn.net/android_tutor/article/details/5772285#" title="view plain" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_plain.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">view plain</a><a href="http://blog.csdn.net/android_tutor/article/details/5772285#" title="copy" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_copy.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">copy</a><div style="position: absolute; left: 521px; top: 1388px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_1" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_1" align="center" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=1&amp;width=18&amp;height=18" wmode="transparent"></div></div></div><ol start="1"><li style="line-height: 18px;">public&nbsp;class&nbsp;Activity&nbsp;extends&nbsp;ApplicationContext&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onCreate(Bundle&nbsp;savedInstanceState);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onStart();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onRestart();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onResume();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onPause();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onStop();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onDestroy();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li></ol></div><p>&nbsp;</p><p style="color: #333333; font-family: Arial; line-height: 26px;">&nbsp;</p><p style="color: #333333; font-family: Arial; line-height: 26px;">为了便于大家更好的理解，我简单的写了一个Demo,不明白Activity周期的朋友们，可以亲手实践一下，大家按照我的步骤来。</p><p style="color: #333333; font-family: Arial; line-height: 26px;">第一步:新建一个Android工程，我这里命名为ActivityDemo.</p><p style="color: #333333; font-family: Arial; line-height: 26px;">第二步:修改ActivityDemo.java(我这里重新写了以上的七种方法，主要用Log打印),代码如下:</p><p style="color: #333333; font-family: Arial; line-height: 26px;"></p><div bg_java"="" style="width: 687.0499877929688px;"><div><div><strong>[java]</strong>&nbsp;<a href="http://blog.csdn.net/android_tutor/article/details/5772285#" title="view plain" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_plain.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">view plain</a><a href="http://blog.csdn.net/android_tutor/article/details/5772285#" title="copy" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_copy.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">copy</a><div style="position: absolute; left: 521px; top: 1899px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_2" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_2" align="center" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=2&amp;width=18&amp;height=18" wmode="transparent"></div></div></div><ol start="1"><li style="line-height: 18px;">package&nbsp;com.tutor.activitydemo;&nbsp;&nbsp;</li><li style="line-height: 18px;">import&nbsp;android.app.Activity;&nbsp;&nbsp;</li><li style="line-height: 18px;">import&nbsp;android.os.Bundle;&nbsp;&nbsp;</li><li style="line-height: 18px;">import&nbsp;android.util.Log;&nbsp;&nbsp;</li><li style="line-height: 18px;">public&nbsp;class&nbsp;ActivityDemo&nbsp;extends&nbsp;Activity&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;static&nbsp;final&nbsp;String&nbsp;TAG&nbsp;=&nbsp;"ActivityDemo";&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;void&nbsp;onCreate(Bundle&nbsp;savedInstanceState)&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super.onCreate(savedInstanceState);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setContentView(R.layout.main);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,&nbsp;"start&nbsp;onCreate~~~");&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #646464;">@Override</span>&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onStart()&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super.onStart();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,&nbsp;"start&nbsp;onStart~~~");&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #646464;">@Override</span>&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onRestart()&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super.onRestart();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,&nbsp;"start&nbsp;onRestart~~~");&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #646464;">@Override</span>&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onResume()&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super.onResume();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,&nbsp;"start&nbsp;onResume~~~");&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #646464;">@Override</span>&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onPause()&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super.onPause();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,&nbsp;"start&nbsp;onPause~~~");&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #646464;">@Override</span>&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onStop()&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super.onStop();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,&nbsp;"start&nbsp;onStop~~~");&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #646464;">@Override</span>&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onDestroy()&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super.onDestroy();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,&nbsp;"start&nbsp;onDestroy~~~");&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">}&nbsp;&nbsp;</li></ol></div><p>&nbsp;</p><p style="color: #333333; font-family: Arial; line-height: 26px;">&nbsp;</p><p style="color: #333333; font-family: Arial; line-height: 26px;">第三步:运行上述工程,效果图如下(没什么特别的):</p><p style="color: #333333; font-family: Arial; line-height: 26px;"><img src="http://hi.csdn.net/attachment/201007/28/0_1280322049kfxQ.gif" alt="" width="372" height="191" style="border: none;" /></p><p style="color: #333333; font-family: Arial; line-height: 26px;">核心在Logcat视窗里,如果你还不会用Logcat你可以看一下我的这篇文章<a href="http://blog.csdn.net/Android_Tutor/archive/2009/12/26/5081713.aspx" style="color: #336699; text-decoration: initial;">&nbsp;Log图文详解(Log.v,Log.d,Log.i,Log.w,Log.e)</a>&nbsp;，我们打开应用时先后执行了onCreate()-&gt;onStart()-&gt;onResume三个方法，看一下LogCat视窗如下:</p><p style="color: #333333; font-family: Arial; line-height: 26px;"><img src="http://hi.csdn.net/attachment/201007/28/0_1280324212Y5nt.gif" alt="" style="border: none;" /></p><p style="color: #333333; font-family: Arial; line-height: 26px;">BACK键：</p><p style="color: #333333; font-family: Arial; line-height: 26px;">当我们按BACK键时，我们这个应用程序将结束，这时候我们将先后调用onPause()-&gt;onStop()-&gt;onDestory()三个方法，如下图所示:</p><p style="color: #333333; font-family: Arial; line-height: 26px;"><img src="http://hi.csdn.net/attachment/201007/28/0_1280324618Bqxb.gif" alt="" style="border: none;" /></p><p style="color: #333333; font-family: Arial; line-height: 26px;">HOME键:</p><p style="color: #333333; font-family: Arial; line-height: 26px;">当我们打开应用程序时，比如浏览器，我正在浏览NBA新闻，看到一半时，我突然想听歌，这时候我们会选择按HOME键，然后去打开音乐应用程序，而当我们按HOME的时候，Activity先后执行了onPause()-&gt;onStop()这两个方法，这时候应用程序并没有销毁。如下图所示:</p><p style="color: #333333; font-family: Arial; line-height: 26px;"><img src="http://hi.csdn.net/attachment/201007/28/0_1280325044k0c7.gif" alt="" style="border: none;" /></p><p style="color: #333333; font-family: Arial; line-height: 26px;">而当我们再次启动ActivityDemo应用程序时，则先后分别执行了onRestart()-&gt;onStart()-&gt;onResume()三个方法，如下图所示:</p><p style="color: #333333; font-family: Arial; line-height: 26px;"><img src="http://hi.csdn.net/attachment/201007/28/0_1280325373Qjq7.gif" alt="" style="border: none;" /></p><p style="color: #333333; font-family: Arial; line-height: 26px;">&nbsp;</p><p style="color: #333333; font-family: Arial; line-height: 26px;">这里我们会引出一个问题，当我们按HOME键，然后再进入ActivityDemo应用时，我们的应用的状态应该是和按HOME键之前的状态是一样的，同样为了方便理解，在这里我将ActivityDemo的代码作一些修改，就是增加一个EditText。</p><p style="color: #333333; font-family: Arial; line-height: 26px;">&nbsp;</p><p style="color: #333333; font-family: Arial; line-height: 26px;">第四步:修改main.xml布局文件（增加了一个EditText),代码如下:</p><p style="color: #333333; font-family: Arial; line-height: 26px;"></p><div bg_java"="" style="width: 687.0499877929688px;"><div><div><strong>[java]</strong>&nbsp;<a href="http://blog.csdn.net/android_tutor/article/details/5772285#" title="view plain" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_plain.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">view plain</a><a href="http://blog.csdn.net/android_tutor/article/details/5772285#" title="copy" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_copy.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">copy</a><div style="position: absolute; left: 521px; top: 4383px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_3" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_3" align="center" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=3&amp;width=18&amp;height=18" wmode="transparent"></div></div></div><ol start="1"><li style="line-height: 18px;">&lt;?xml&nbsp;version="1.0"&nbsp;encoding="utf-8"?&gt;&nbsp;&nbsp;</li><li style="line-height: 18px;">&lt;LinearLayout&nbsp;xmlns:android="http://schemas.android.com/apk/res/android"&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;android:orientation="vertical"&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;android:layout_width="fill_parent"&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;android:layout_height="fill_parent"&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&gt;&nbsp;&nbsp;</li><li style="line-height: 18px;">&lt;TextView&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;android:layout_width="fill_parent"&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;android:layout_height="wrap_content"&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;android:text="@string/hello"&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;/&gt;&nbsp;&nbsp;</li><li style="line-height: 18px;">&lt;EditText&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;android:id="@+id/editText"&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;android:layout_width="fill_parent"&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;android:layout_height="wrap_content"&nbsp;&nbsp;</li><li style="line-height: 18px;">/&gt;&nbsp;&nbsp;</li><li style="line-height: 18px;">&lt;/LinearLayout&gt;&nbsp;&nbsp;</li></ol></div><p>&nbsp;</p><p style="color: #333333; font-family: Arial; line-height: 26px;">第五步:然后其他不变，运行ActivityDemo程序,在EditText里输入如"Frankie"字符串(如下图:)</p><p style="color: #333333; font-family: Arial; line-height: 26px;"><img src="http://hi.csdn.net/attachment/201007/28/0_1280326575HhRQ.gif" alt="" style="border: none;" /></p><p style="color: #333333; font-family: Arial; line-height: 26px;">&nbsp;</p><p style="color: #333333; font-family: Arial; line-height: 26px;">这时候，大家可以按一下HOME键，然后再次启动ActivityDemo应用程序，这时候EditText里并没有我们输入的"Frankie"字样，如下图:</p><p style="color: #333333; font-family: Arial; line-height: 26px;"><img src="http://hi.csdn.net/attachment/201007/28/0_12803267326xiQ.gif" alt="" style="border: none;" /></p><p style="color: #333333; font-family: Arial; line-height: 26px;">这显然不能称得一个合格的应用程序，所以我们需要在Activity几个方法里自己实现，如下第六步所示:</p><p style="color: #333333; font-family: Arial; line-height: 26px;">第六步修改ActivityDemo.java代码如下:</p><p style="color: #333333; font-family: Arial; line-height: 26px;"></p><div bg_java"="" style="width: 687.0499877929688px;"><div><div><strong>[java]</strong>&nbsp;<a href="http://blog.csdn.net/android_tutor/article/details/5772285#" title="view plain" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_plain.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">view plain</a><a href="http://blog.csdn.net/android_tutor/article/details/5772285#" title="copy" style="background-image: url(http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/images/default/ico_copy.gif); padding: 1px; display: inline-block; width: 16px; height: 16px; text-indent: -2000px; background-position: 0% 0%; background-repeat: no-repeat no-repeat;">copy</a><div style="position: absolute; left: 521px; top: 5592px; width: 18px; height: 18px; z-index: 99;"><embed id="ZeroClipboardMovie_4" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="18" height="18" name="ZeroClipboardMovie_4" align="center" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=4&amp;width=18&amp;height=18" wmode="transparent"></div></div></div><ol start="1"><li style="line-height: 18px;">package&nbsp;com.tutor.activitydemo;&nbsp;&nbsp;</li><li style="line-height: 18px;">import&nbsp;android.app.Activity;&nbsp;&nbsp;</li><li style="line-height: 18px;">import&nbsp;android.os.Bundle;&nbsp;&nbsp;</li><li style="line-height: 18px;">import&nbsp;android.util.Log;&nbsp;&nbsp;</li><li style="line-height: 18px;">import&nbsp;android.widget.EditText;&nbsp;&nbsp;</li><li style="line-height: 18px;">public&nbsp;class&nbsp;ActivityDemo&nbsp;extends&nbsp;Activity&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;static&nbsp;final&nbsp;String&nbsp;TAG&nbsp;=&nbsp;"ActivityDemo";&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;EditText&nbsp;mEditText;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;//定义一个String&nbsp;类型用来存取我们EditText输入的值&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;String&nbsp;mString;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;void&nbsp;onCreate(Bundle&nbsp;savedInstanceState)&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super.onCreate(savedInstanceState);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setContentView(R.layout.main);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mEditText&nbsp;=&nbsp;(EditText)findViewById(R.id.editText);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,&nbsp;"start&nbsp;onCreate~~~");&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #646464;">@Override</span>&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onStart()&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super.onStart();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,&nbsp;"start&nbsp;onStart~~~");&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;//当按HOME键时，然后再次启动应用时，我们要恢复先前状态&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #646464;">@Override</span>&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onRestart()&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super.onRestart();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mEditText.setText(mString);&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,&nbsp;"start&nbsp;onRestart~~~");&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #646464;">@Override</span>&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onResume()&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super.onResume();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,&nbsp;"start&nbsp;onResume~~~");&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;//当我们按HOME键时，我在onPause方法里，将输入的值赋给mString&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #646464;">@Override</span>&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onPause()&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super.onPause();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mString&nbsp;=&nbsp;mEditText.getText().toString();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,&nbsp;"start&nbsp;onPause~~~");&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #646464;">@Override</span>&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onStop()&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super.onStop();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,&nbsp;"start&nbsp;onStop~~~");&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #646464;">@Override</span>&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;void&nbsp;onDestroy()&nbsp;{&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super.onDestroy();&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log.e(TAG,&nbsp;"start&nbsp;onDestroy~~~");&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</li><li style="line-height: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="line-height: 18px;">}&nbsp;&nbsp;</li></ol></div><p>&nbsp;</p><p style="color: #333333; font-family: Arial; line-height: 26px;">第七步:重新运行ActivityDemo程序，重复第五步操作，当我们按HOME键时，再次启动应用程序时，EditText里有上次输入的"Frankie"字样，如下图如示:</p><p style="color: #333333; font-family: Arial; line-height: 26px;"><img src="http://hi.csdn.net/attachment/201007/28/0_1280327855y53e.gif" alt="" style="border: none;" /></p><p style="color: #333333; font-family: Arial; line-height: 26px;">OK,大功基本告成，这时候大家可以在回上面看一下Activity生命周期图，我想大家应该完全了解了Activity的生命周期了，不知道你了解了没？</p><img src ="http://www.blogjava.net/hwpok/aggbug/398122.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/hwpok/" target="_blank">惠万鹏</a> 2013-04-20 13:41 <a href="http://www.blogjava.net/hwpok/archive/2013/04/20/398122.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>A folder failed to be renamed or moved--安装Android SDK的问题 </title><link>http://www.blogjava.net/hwpok/archive/2012/11/03/390750.html</link><dc:creator>惠万鹏</dc:creator><author>惠万鹏</author><pubDate>Sat, 03 Nov 2012 14:19:00 GMT</pubDate><guid>http://www.blogjava.net/hwpok/archive/2012/11/03/390750.html</guid><wfw:comment>http://www.blogjava.net/hwpok/comments/390750.html</wfw:comment><comments>http://www.blogjava.net/hwpok/archive/2012/11/03/390750.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/hwpok/comments/commentRss/390750.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/hwpok/services/trackbacks/390750.html</trackback:ping><description><![CDATA[<div style="position: static; filter: none; line-height: 20px; overflow-x: hidden; overflow-y: hidden; zoom: 1 !important; word-wrap: break-word; visibility: visible !important; color: #333333; font-size: 14px; word-break: normal">
<p><span style="color: #ff0000">-=Warning !=-</span><br /><span style="color: #ff0000">A folder failed to be renamed or moved.On Windows this typically means</span><br /><span style="color: #ff0000">that&nbsp;&nbsp;a program is using that folder (for example Windows Explorer or your anti-virus software.)</span><br /><span style="color: #ff0000">Please momentarily deactivate your anti-virus software</span><br /><span style="color: #ff0000">Please also close any running,programs that may be accessing the directory</span><br /><span style="color: #ff0000">'G:\software\android-sdk-windows\tools'.</span><br /><span style="color: #ff0000">When ready,press Yes to try again.</span></p>
<p>&nbsp;解决方法有两种：</p>
<p><strong>第一种方法(貌似是从国外的网站上找来)：</strong></p>
<p>1, 复制 tools目录 为一个新的目录 tools-copy ,此时在android-sdk-windows 目录下有两个目录 tools 和 tools-copy<br />2, 在tools-copy目录运行 android.bat ，这样就可以正常 update all 了<br />3,&nbsp;之后，关闭 sdk,&nbsp;<br />4, 在 android-sdk-windows 目录运行 SDK Setup.exe</p>
<p>&nbsp;</p>
<p><strong>第二种方法：</strong></p>
<p>&nbsp;1,&nbsp;进入sdk的temp文件夹，下载好后会有一个tools_r10-windows.zip(版本号可能会不一样，如r09)<br />&nbsp;2,&nbsp;解压此文件，如解压到tools_r10-windows目录<br />&nbsp;3,&nbsp;进入tools_r10-windows文件夹，将tools_r1006-windows里的文件复制<br />&nbsp;4,&nbsp;覆盖掉sdk根目录的tools文件夹中的文件</p></div><img src ="http://www.blogjava.net/hwpok/aggbug/390750.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/hwpok/" target="_blank">惠万鹏</a> 2012-11-03 22:19 <a href="http://www.blogjava.net/hwpok/archive/2012/11/03/390750.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>