﻿<?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-level0-文章分类-android日志</title><link>http://www.blogjava.net/level0/category/47451.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 09 Feb 2011 00:35:48 GMT</lastBuildDate><pubDate>Wed, 09 Feb 2011 00:35:48 GMT</pubDate><ttl>60</ttl><item><title>2011.01.02 一些基本的Layout控件</title><link>http://www.blogjava.net/level0/articles/342157.html</link><dc:creator>level0</dc:creator><author>level0</author><pubDate>Sun, 02 Jan 2011 04:00:00 GMT</pubDate><guid>http://www.blogjava.net/level0/articles/342157.html</guid><wfw:comment>http://www.blogjava.net/level0/comments/342157.html</wfw:comment><comments>http://www.blogjava.net/level0/articles/342157.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/level0/comments/commentRss/342157.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/level0/services/trackbacks/342157.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: package&nbsp;level0.exercise.layout;import&nbsp;android.app.Activity;import&nbsp;android.os.Bundle;import&nbsp;android.view.View;import&nbsp;android.widget.AdapterView;import&nbsp;android....&nbsp;&nbsp;<a href='http://www.blogjava.net/level0/articles/342157.html'>阅读全文</a><img src ="http://www.blogjava.net/level0/aggbug/342157.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/level0/" target="_blank">level0</a> 2011-01-02 12:00 <a href="http://www.blogjava.net/level0/articles/342157.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>cmd100论坛Mars老师的视频目录整理（1到17）</title><link>http://www.blogjava.net/level0/articles/341553.html</link><dc:creator>level0</dc:creator><author>level0</author><pubDate>Sun, 26 Dec 2010 02:51:00 GMT</pubDate><guid>http://www.blogjava.net/level0/articles/341553.html</guid><wfw:comment>http://www.blogjava.net/level0/comments/341553.html</wfw:comment><comments>http://www.blogjava.net/level0/articles/341553.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/level0/comments/commentRss/341553.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/level0/services/trackbacks/341553.html</trackback:ping><description><![CDATA[<style type="text/css">p { margin-bottom: 0.21cm; }code.cjk { font-family: "DejaVu Sans",monospace; }code.ctl { font-family: "DejaVu Sans Mono",monospace; }a:link {  }</style>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">01-01-Android</font>平台一日游</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font>，观赏<font face="DejaVu Serif, serif">Android</font>的全景地图：</p>
<p style="margin-bottom: 0cm;">
给出了<font face="DejaVu Serif, serif">Google</font>官方发布的<font face="DejaVu Serif, serif">Android</font>的<font face="DejaVu Serif, serif">4</font>层结构图。最底层为<font face="DejaVu Serif, serif">Linux
Kernel</font>（主要一些与硬件相关的最底层的操作，比如各种驱动，内存管理，进程管理等），第二层为<font face="DejaVu Serif, serif">Libraries</font>和<font face="DejaVu Serif, serif">Android
runtime</font>（<font face="DejaVu Serif, serif">Library</font>是一堆由<font face="DejaVu Serif, serif">C/C++</font>编写的基础库，<font face="DejaVu Serif, serif">Android</font>主要包括一个<font face="DejaVu Serif, serif">Dalvik</font>虚拟机和<font face="DejaVu Serif, serif">core
libraries</font>），第三层是<font face="DejaVu Serif, serif">application
framework</font>（顾名思义是各种的框架，用于对第四层的应用提供接口和进行管理），最高层是<font face="DejaVu Serif, serif">applications</font>（就是平常呢些直接和手机用户进行交互的东西）。</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font>，<font face="DejaVu Serif, serif">Android
VS Iphone</font></p>
<p style="margin-bottom: 0cm;">     大致地介绍了两个手机操作系统平台之间的差异和两个公司之间的敌对关系。</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">3</font>，<font face="DejaVu Serif, serif">Android</font>常用组件（四大天王）</p>
<p style="margin-bottom: 0cm;">     <font face="DejaVu Serif, serif">Activity</font>：最漂亮，门面功夫要做足。</p>
<p style="margin-bottom: 0cm;">     <font face="DejaVu Serif, serif">Intent</font>：最牛力，运输数据全赖他。</p>
<p style="margin-bottom: 0cm;">     <font face="DejaVu Serif, serif">Service</font>：最低调，后台服务看不到。</p>
<p style="margin-bottom: 0cm;">     <font face="DejaVu Serif, serif">Content
Provider</font>：最博学，数据存放集中地。</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">4</font>，<font face="DejaVu Serif, serif">Android</font>开发工具</p>
<p style="margin-bottom: 0cm;">     常用<font face="DejaVu Serif, serif">IDE</font>：<font face="DejaVu Serif, serif">Eclipse</font>（配上插件<font face="DejaVu Serif, serif">ADT</font>）</p>
<p style="margin-bottom: 0cm;">     开发工具包：<font face="DejaVu Serif, serif">Android
SDK</font>（<font face="DejaVu Serif, serif">2010.12.06</font>发布了<font face="DejaVu Serif, serif">2.3</font>的版本）
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">5</font>，参观<font face="DejaVu Serif, serif">Android</font>王国的金矿</p>
<p style="margin-bottom: 0cm;">
大致介绍了通过<font face="DejaVu Serif, serif">Android</font>的两种赚钱的方法：卖应用和嵌入广告。（<font face="DejaVu Serif, serif">Mars</font>推荐第二种）</p>
<p style="margin-bottom: 0cm;">
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">01-02-</font>搭建<font face="DejaVu Serif, serif">Android</font>开发环境</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font>，<font face="DejaVu Serif, serif">Android
SDK</font>的安装</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font>，<font face="DejaVu Serif, serif">ADT</font>的安装与配置</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">3</font>，<font face="DejaVu Serif, serif">Android</font>的模拟器配置</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">/***</font>官方给出了很详细的安装文档，这里不详细展开，步骤大致如下：</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">1</font>）安装和配置<font face="DejaVu Serif, serif">JDK</font>和<font face="DejaVu Serif, serif">JRE1.5</font>（<font face="DejaVu Serif, serif">1.6</font>更佳）</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">2</font>）安装带<font face="DejaVu Serif, serif">JavaSDK</font>的<font face="DejaVu Serif, serif">Eclipse3.4</font>或者<font face="DejaVu Serif, serif">3.5</font></p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">3</font>）下载<font face="DejaVu Serif, serif">Android
SDK</font>（较为准确的说法是<font face="DejaVu Serif, serif">Android
SDK download platform</font>）</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">4</font>）在<font face="DejaVu Serif, serif">Eclipse</font>中安装<font face="DejaVu Serif, serif">ADT</font>插件</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">5</font>）配置<font face="DejaVu Serif, serif">Android
SDK</font>的路径</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">6</font>）下载虚拟机和相关文档（和一些选用的功能）<font face="DejaVu Serif, serif">***/</font></p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">01-03-say_hello_to_Android</font></p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font>，创建一个<font face="DejaVu Serif, serif">Android</font>应用程序的步骤</p>
<p style="margin-bottom: 0cm;">     （略）</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font>，<font face="DejaVu Serif, serif">Android</font>应用程序目录结构</p>
<p style="margin-bottom: 0cm;">     <font face="DejaVu Serif, serif">src:short
for source</font>，存放源代码的地方。</p>
<p style="margin-bottom: 0cm;">     <font face="DejaVu Serif, serif">gen</font>：主要就是<font face="DejaVu Serif, serif">R.java</font>文件存放的位置。</p>
<p style="margin-bottom: 0cm;">
<font face="DejaVu Serif, serif">asset:</font>存放资源文件的文件夹，不会在<font face="DejaVu Serif, serif">R.java</font>中自动生成对应的数据。</p>
<p style="margin-bottom: 0cm;">     <font face="DejaVu Serif, serif">res</font>：<font face="DejaVu Serif, serif">short
for resource</font>，存放资源文件的文件夹，并在<font face="DejaVu Serif, serif">R.java</font>里面有对应的数据。</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">3</font>，<font face="DejaVu Serif, serif">AndroidManifest.xml</font>文件的作用</p>
<p style="margin-bottom: 0cm;">     每编写一个活动都需要在这里注册。</p>
<p style="margin-bottom: 0cm;">     其中的<font face="DejaVu Serif, serif">&lt;intent
filter&gt;</font>是区分应用启动时优先启动哪个<font face="DejaVu Serif, serif">Activity</font>的标记。</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">4</font>，<font face="DejaVu Serif, serif">Android</font>相关文件资源的作用</p>
<p style="margin-bottom: 0cm;">      提到了一个名为&#8220;键值对&#8221;的概念（<font face="DejaVu Serif, serif">XML</font>的？要查阅相关资料了）</p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">01-04-Activity</font>初步</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font>，<font face="DejaVu Serif, serif">Activity</font>的主要作用</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font>，创建一个<font face="DejaVu Serif, serif">Activity</font>的方法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">3</font>，在<font face="DejaVu Serif, serif">AndroidManifest.xml</font>文件当中注册应用<font face="DejaVu Serif, serif">Activity</font>的方法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">4</font>，在<font face="DejaVu Serif, serif">Android</font>当中添加控件的方法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">/***</font>按作者的说法是：<font face="DejaVu Serif, serif">Activity</font>不好翻译，反正就是理解成一个与用户进行交互的界面，但是一个<font face="DejaVu Serif, serif">Activity</font>本身只是一个近乎空白容器，要实现交互界面就需要在上面放入各种适用的控件。</p>
<p style="margin-bottom: 0cm;">
一个<font face="DejaVu Serif, serif">Activity</font>要继承<font face="DejaVu Serif, serif">Activity</font>类，而且至少要实现<font face="DejaVu Serif, serif">onCreate()</font>的方法。并且记得要在<font face="DejaVu Serif, serif">AndroidManifest.xml</font>中进行注册</p>
<p style="margin-bottom: 0cm;">
每个<font face="DejaVu Serif, serif">Activity</font>一般都对应着一个<font face="DejaVu Serif, serif">layout</font>，在<font face="DejaVu Serif, serif">layout</font>中定义和放置控件，控件内容可以直接在<font face="DejaVu Serif, serif">xml</font>中编写，但<font face="DejaVu Serif, serif">Mars</font>的做法是添加<font face="DejaVu Serif, serif">id</font>，然后在源代码中用<font face="DejaVu Serif, serif">findViewById()</font>方法来进行引用和写入内容。（感觉在<font face="DejaVu Serif, serif">xml</font>里面写比较方便，用着顺手就是了）<font face="DejaVu Serif, serif">***/</font></p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">01-05-Activity</font>和<font face="DejaVu Serif, serif">Intent</font></p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font>，多个<font face="DejaVu Serif, serif">Activity</font>之间的关系</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font>，<font face="DejaVu Serif, serif">Intent</font>的基本作用</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">3</font>，在一个<font face="DejaVu Serif, serif">Activity</font>中启动另一个<font face="DejaVu Serif, serif">Activity</font>的方法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">4</font>，使用<font face="DejaVu Serif, serif">Intent</font>在<font face="DejaVu Serif, serif">Activity</font>中传递数据的基本方法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">/***</font>可以用<font face="DejaVu Serif, serif">Intent</font>对多个<font face="DejaVu Serif, serif">Activity</font>之间切换（这些<font face="DejaVu Serif, serif">Activity</font>可以在同一个应用程序当中也可以不再同一个应用程序当中）。<font face="DejaVu Serif, serif">Intent</font>可以在<font face="DejaVu Serif, serif">Activity</font>之间进行切换和传输数据（<font face="DejaVu Serif, serif">data</font>或者<font face="DejaVu Serif, serif">Extras</font>键值对）。<font face="DejaVu Serif, serif">Intent</font>的作用不限于启动活动，<font face="DejaVu Serif, serif">Intent</font>可以启动很多<font face="DejaVu Serif, serif">component</font>，比如<font face="DejaVu Serif, serif">broadcast</font>等。<font face="DejaVu Serif, serif">Mars</font>认为<font face="DejaVu Serif, serif">Intent</font>虽然一般被翻译成意图但确实不是太好的翻译，他目前也没有想到较好的就暂时先吧<font face="DejaVu Serif, serif">Intent</font>看成一种请求。</p>
<p style="margin-bottom: 0cm;">原<font face="DejaVu Serif, serif">ppt</font>：</p>
<p style="margin-bottom: 0cm;">一个<font face="DejaVu Serif, serif">Intent</font>对象包含了一组信息：</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1,Component
name </font>启动组件的名称（组件可以是活动啊广播啊很多）</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2,Action
</font>要求组件执行的动作（系统给除了很多参数，参看<font face="DejaVu Serif, serif">documentation</font>）</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">3,Data
</font>由原组件到新组件传输的数据</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">4,Category
</font>没讲</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">5,Extras
</font>也是数据，不过是键值对（什么是键值对？理解成两个字符串？）</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">6,Flags
</font>没讲</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">***/</font></p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">01-06-Android</font>当中的常见控件</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font>，<font face="DejaVu Serif, serif">TextView</font>的使用方法（显示类型文本框）</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font>，<font face="DejaVu Serif, serif">EditText</font>的使用方法（可输入类型文本框）</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">3</font>，<font face="DejaVu Serif, serif">Button</font>的使用方法（按钮）</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">4</font>，<font face="DejaVu Serif, serif">Menu</font>的使用方法（菜单）</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">/***</font>我在<font face="DejaVu Serif, serif">Mars</font>操作中所注意到的东西：</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">1</font>）为所以显示类型文本框中，<font face="DejaVu Serif, serif">setText()</font>方法中最好是在<font face="DejaVu Serif, serif">string</font>中建立键值对并进行引用，这样有助与实现应用简化了各种语言的的翻译问题。（当然目前不认为写的应用会被翻译，不过好习惯是要提前养成的）</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">2</font>）<font face="DejaVu Serif, serif">Mars</font>老师好会善用<font face="DejaVu Serif, serif">Eclipse</font>强大的编辑功能，强大的快捷键比如<font face="DejaVu Serif, serif">Ctrl+Shift+O
; Alt+. ; Ctrl+1</font>要多多使用之</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">3</font>）关于<font face="DejaVu Serif, serif">OptionsMenu</font>的两个方法：<font face="DejaVu Serif, serif">onCreateOptionsMenus()</font>和<font face="DejaVu Serif, serif">OnOptionsMenuSelected()</font></p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">***/</font></p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">01-07-Activity</font>生命周期（一）</p>
<p style="margin-bottom: 0cm;">七个生命周期：<font face="DejaVu Serif, serif"><br />
</font>（<font face="DejaVu Serif, serif">1</font>）<font face="DejaVu Serif, serif">onCreate()</font>在<font face="DejaVu Serif, serif">Activity</font>第一次启动的时候执行；在这里编写实现<font face="DejaVu Serif, serif">Activity</font>的<font face="DejaVu Serif, serif">layout</font>的代码，并添加对应的监听器。</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">2</font>）<font face="DejaVu Serif, serif">onStart()</font>在<font face="DejaVu Serif, serif">Activity</font>能被用户看到的时候执行</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">3</font>）<font face="DejaVu Serif, serif">onResume()</font>在<font face="DejaVu Serif, serif">Activity</font>能获得用户焦点的时候执行（能与用户进行交互的时候）</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">4</font>）<font face="DejaVu Serif, serif">onPause()</font>在<font face="DejaVu Serif, serif">Activity</font>当中启动另一个<font face="DejaVu Serif, serif">Activity</font>的时候执行</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">5</font>）<font face="DejaVu Serif, serif">onStop()</font>在<font face="DejaVu Serif, serif">Activity</font>不能被用户看到的时候执行（被另外一个<font face="DejaVu Serif, serif">Activity</font>完全覆盖）</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">6</font>）<font face="DejaVu Serif, serif">onRestart()</font>在处于<font face="DejaVu Serif, serif">stop()</font>状态的<font face="DejaVu Serif, serif">Activity</font>重新启动的时候（区别于<font face="DejaVu Serif, serif">onCreate()</font>的初次启动）</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">7</font>）<font face="DejaVu Serif, serif">onDestroy()</font>在<font face="DejaVu Serif, serif">Activity</font>被销毁的时候（两种情况：用户明确调用了<font face="DejaVu Serif, serif">finish()</font>方法，或者在系统资源不足的时候系统自动清理处于后台状态的<font face="DejaVu Serif, serif">Activity</font>）</p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">01-08-Activity</font>的生命周期（二）</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font>，<font face="DejaVu Serif, serif">Task</font>的基本概念</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font>，<font face="DejaVu Serif, serif">Activity</font>与<font face="DejaVu Serif, serif">Task</font>之间的关系</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">3</font>，对话框风格<font face="DejaVu Serif, serif">Activity</font>的使用方法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">/***</font></p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">1</font>）<font face="DejaVu Serif, serif">Task
is a stack of
Activity.</font>所以<font face="DejaVu Serif, serif">Task</font>只能进行<font face="DejaVu Serif, serif">push</font>和<font face="DejaVu Serif, serif">pop</font>操作，内部不能进行重新排序。<font face="DejaVu Serif, serif">Android</font>显示的始终时<font face="DejaVu Serif, serif">Task</font>最上面的<font face="DejaVu Serif, serif">Activity</font>。<font face="DejaVu Serif, serif">Task</font>的一个重要意义：使<font face="DejaVu Serif, serif">Task</font>中所以<font face="DejaVu Serif, serif">Activity</font>成为一个整体，给用户较好的体验。</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">2</font>）如果在调用另一个<font face="DejaVu Serif, serif">Activity</font>的时候调用原<font face="DejaVu Serif, serif">Activity</font>的<font face="DejaVu Serif, serif">finish()</font>方法，原<font face="DejaVu Serif, serif">Activity</font>会被销毁（即不再在栈中）</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">3</font>）<font face="DejaVu Serif, serif">Android</font>在系统资源不够用的时候会自动清理一些<font face="DejaVu Serif, serif">Activity</font>，当<font face="DejaVu Serif, serif">Activity</font>处于<font face="DejaVu Serif, serif">onPause()</font>，<font face="DejaVu Serif, serif">onStop</font>，<font face="DejaVu Serif, serif">onDestroy()</font>的状态时，则有可能会被<font face="DejaVu Serif, serif">kill</font>掉</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">4</font>）一个<font face="DejaVu Serif, serif">Activity</font>在<font face="DejaVu Serif, serif">AndroidManifest</font>中注册的时候，可以通过设置<font face="DejaVu Serif, serif">theme</font>为<font face="DejaVu Serif, serif">theme.dialog</font>的方法显示为对话框风格（就是不会完全遮挡住原<font face="DejaVu Serif, serif">Activity</font>的那种，在实际手机应用中相当常用）<font face="DejaVu Serif, serif">***/</font></p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">01-09-Activity</font>布局初步<font face="DejaVu Serif, serif">(</font>一<font face="DejaVu Serif, serif">)</font></p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font>，<font face="DejaVu Serif, serif">LinearLayout</font>的使用方法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font>，<font face="DejaVu Serif, serif">TableLayout</font>的使用方法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">/***</font></p>
<p style="margin-bottom: 0cm;">大致介绍了线性和表格两种常用布局和它们在<font face="DejaVu Serif, serif">xml</font>中的一些属性比如<font face="DejaVu Serif, serif">gravity,padding,orientation,weight,singleLine</font>等，详细可以参看<font face="DejaVu Serif, serif">documentation</font></p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">***/</font></p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">01-10-Activity</font>布局初步<font face="DejaVu Serif, serif">(</font>二<font face="DejaVu Serif, serif">)</font></p>
<p style="margin-bottom: 0cm;">大致介绍了<font face="DejaVu Serif, serif">Layout</font>的相互嵌套。（相互嵌套能够构造更加复杂和华丽的布局）</p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">01-11-Activity</font>的布局初步（三）</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font>，相对布局的基本概念</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font>，相对布局与其他布局的区别</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">3</font>，相对布局的常用属性介绍</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">/***</font>相对布局用的是跟线性或表格布局不同的布局方式，它布局采用控件的相对位置来进行设置。具体参数参看<font face="DejaVu Serif, serif">SDK</font>或者视频<font face="DejaVu Serif, serif">***/</font></p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">01-12-Android</font>常见控件（二）</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font>，<font face="DejaVu Serif, serif">RadioGroup</font>和<font face="DejaVu Serif, serif">RadioButton</font>的使用方法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font>，<font face="DejaVu Serif, serif">CheckBox</font>的使用方法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">3</font>，<font face="DejaVu Serif, serif">Toast</font>的基本用法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">/***</font></p>
<p style="margin-bottom: 0cm;">大致介绍了三种控件：</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">RadioGroup&amp;&amp;RadioButton
</font>单选框</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">CheckBox
</font>复选框</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">toast</font>：（吐司？感觉就是小型提示框）</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">A
toast is a view containing a quick little message for the user.</font></p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">***/</font></p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">01-13-</font>常用控件（三）</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font>，<font face="DejaVu Serif, serif">ProgressBar</font>的使用方法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font>，<font face="DejaVu Serif, serif">ListView</font>的使用方法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">/***</font></p>
<p style="margin-bottom: 0cm;">介绍了进度条和列表视图的实现方法，这两个是比较复杂的控件<font face="DejaVu Serif, serif">,</font>其中<font face="DejaVu Serif, serif">ListView</font>涉及<font face="DejaVu Serif, serif">Adaptor</font>，在使用之前要好好参看视频和<font face="DejaVu Serif, serif">SDK
Documentation</font></p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">***/</font></p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">01-14-Handler</font>的使用（一）</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font>，<font face="DejaVu Serif, serif">Handler</font>的基本概念</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font>，<font face="DejaVu Serif, serif">Handler</font>的基本使用方法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">3</font>，使用<font face="DejaVu Serif, serif">Handler</font>更新<font face="DejaVu Serif, serif">ProgressBar</font></p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">/***</font></p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">1</font>）<font face="DejaVu Serif, serif">A
Handler allows you to send and process <code class="western"><a>Message</a></code>
and Runnable objects associated with a thread's <code class="western"><a>MessageQueue</a></code>.
Each Handler instance is associated with a single thread and that
thread's message queue. When you create a new Handler, it is bound to
the thread / message queue of the thread that is creating it -- from
that point on, it will deliver messages and runnables to that message
queue and execute them as they come out of the message queue. </font>
</p>
<p style="margin-bottom: 0cm;">一个<font face="DejaVu Serif, serif">Handler</font>允许你送出或者处理<font face="DejaVu Serif, serif">Message</font>和关联着一个线程消息队列的<font face="DejaVu Serif, serif">Runnable</font>对象。每一个<font face="DejaVu Serif, serif">Handler</font>实力都联系唯一一个线程和它的消息队列。当你创建一个<font face="DejaVu Serif, serif">Handler</font>的时候，他必须绑定到那个创建它的线程的或者他的消息队列上面——从那之后，他会传递信息和<font face="DejaVu Serif, serif">Runnable</font>到消息队列和在他们从消息对列出来的时候执行他们。（目前我理解成<font face="DejaVu Serif, serif">Handler</font>是一个操作台，而且只能唯一绑定一个线程和它的消息队列的。）</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">2</font>）<font face="DejaVu Serif, serif">Mars</font>老师给出的参考代码时用<font face="DejaVu Serif, serif">Handler</font>操作一条进度条，中间涉及到了<font face="DejaVu Serif, serif">Runnable</font>和消息队列的通信问题。通信的时候有<font face="DejaVu Serif, serif">arg1,arg2</font>两个<font face="DejaVu Serif, serif">int</font>类型的变量，可以减少系统的消耗。</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">***/</font></p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">01-15-Handler</font>的使用（二）</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font>，<font face="DejaVu Serif, serif">Handler</font>与线程</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font>，<font face="DejaVu Serif, serif">Bundle</font>的用法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">3</font>，在新线程当中处理小的的方法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">/***</font></p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">1</font>）在之前的例子中，如果直接用<font face="DejaVu Serif, serif">handler.post(Runnable)</font>方法启动<font face="DejaVu Serif, serif">Runnable</font>对象，<font face="DejaVu Serif, serif">Android</font>默认不会创建新的线程。而是直接把<font face="DejaVu Serif, serif">Runnable</font>的<font face="DejaVu Serif, serif">run()</font>方法放入到主线程的之星队列当中去。</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">2</font>）如果想真正实现两个线程的并行运行，<font face="DejaVu Serif, serif">Mars</font>老师演示了两种方法，第一种是在<font face="DejaVu Serif, serif">Java</font>中用<font face="DejaVu Serif, serif">Thread
t = new
Thread(Runnable)</font>和<font face="DejaVu Serif, serif">t.start()</font>来启动新的线程。不知道出于什么样的原因（估计是这样做比较消耗内存），所以<font face="DejaVu Serif, serif">Mars</font>老师推荐的是另外一种方法——<font face="DejaVu Serif, serif">looper</font>，但一般不会直接创建<font face="DejaVu Serif, serif">Looper</font>，而是使用用<font face="DejaVu Serif, serif">HandlerThread(Looper)</font>来创建一个与<font face="DejaVu Serif, serif">Lopper</font>关联的<font face="DejaVu Serif, serif">HandlerThread</font>实例，然后使<font face="DejaVu Serif, serif">HandlerThread.start()</font>，那么<font face="DejaVu Serif, serif">Looper</font>就启动起来了，然后使用<font face="DejaVu Serif, serif">sendToTarget</font>来触发<font face="DejaVu Serif, serif">Handler</font>中间的<font face="DejaVu Serif, serif">handleMessage</font>方法就可以实现线程了。（思路有点乱，具体再看视频吧）</p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">3</font>）<font face="DejaVu Serif, serif">Bundle</font>，目前理解成是一个简化的<font face="DejaVu Serif, serif">map</font>就可以了（简化是指<font face="DejaVu Serif, serif">Bundle</font>的键只能是字符串而且对应的值一般是<font face="DejaVu Serif, serif">primitive</font>，而<font face="DejaVu Serif, serif">map</font>的键值都是<font face="DejaVu Serif, serif">Object</font>），常用于传递一捆数据。</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">***/</font></p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">01-16-SQLite</font>使用方法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font>，<font face="DejaVu Serif, serif">SQLite</font>介绍</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font>，<font face="DejaVu Serif, serif">SQLiteOpenHelper</font>的用法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">3</font>，使用<font face="DejaVu Serif, serif">adb</font>访问<font face="DejaVu Serif, serif">SQLite</font></p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">4</font>，增，删，改，查</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">/***</font></p>
<p style="margin-bottom: 0cm;">由于本人对数据库不太了解，而且暂时也拍不上什么用场，这节视频先跳过。</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">***/</font></p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">01-17-</font>调试程序</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font>，<font face="DejaVu Serif, serif">DDSM</font>（<font face="DejaVu Serif, serif">Dalvik
Debug Monitor Service</font>）的使用</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font>，常用程序调试方法</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">/***</font></p>
<p style="margin-bottom: 0cm;">大致学习了如何利用<font face="DejaVu Serif, serif">logcat</font>和<font face="DejaVu Serif, serif">DDSM</font>调试程序，<font face="DejaVu Serif, serif">DDSM</font>视图中可以重启失去链接之后的虚拟机，以及对虚拟机进行数据导入导出工作，最牛掰的是当虚拟机连接断掉之后可以在这里重启<font face="DejaVu Serif, serif">adb</font>来解决问题。利用<font face="DejaVu Serif, serif">logcat</font>可以提取应用运行过程中的信息（根据重要程度分成五个档位而且向下兼容）。使用<font face="DejaVu Serif, serif">Android</font>提供的<font face="DejaVu Serif, serif">Log.d()</font>方法结合适当的<font face="DejaVu Serif, serif">filter</font>可以处理条是信息。</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">***/</font></p>
<img src ="http://www.blogjava.net/level0/aggbug/341553.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/level0/" target="_blank">level0</a> 2010-12-26 10:51 <a href="http://www.blogjava.net/level0/articles/341553.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>个人关于ActivityList的学习探讨</title><link>http://www.blogjava.net/level0/articles/341552.html</link><dc:creator>level0</dc:creator><author>level0</author><pubDate>Sun, 26 Dec 2010 02:47:00 GMT</pubDate><guid>http://www.blogjava.net/level0/articles/341552.html</guid><wfw:comment>http://www.blogjava.net/level0/comments/341552.html</wfw:comment><comments>http://www.blogjava.net/level0/articles/341552.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/level0/comments/commentRss/341552.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/level0/services/trackbacks/341552.html</trackback:ping><description><![CDATA[<style type="text/css">p { margin-bottom: 0.21cm; }code.cjk { font-family: "DejaVu Sans",monospace; }code.ctl { font-family: "DejaVu Sans Mono",monospace; }a:link {  }</style>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">ListActivity</font>：</p>
<p style="margin-bottom: 0cm;">一：相关概念简介（翻译自官方文档的<font face="DejaVu Serif, serif">class
overview</font>）</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">An
activity that displays a list of items by binding to a data source
such as an array or Cursor, and exposes event handlers when the user
selects an item. </font>
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">ListActivity
hosts a ListView object that can be bound to different data sources,
typically either an array or a Cursor holding query results. Binding,
screen layout, and row layout are discussed in the following
sections. </font>
</p>
<p style="margin-bottom: 0cm;"><font color="#008000"><font face="DejaVu Serif, serif"><span style="background: none repeat scroll 0% 0% transparent;">ListActivity</span></font><span style="background: none repeat scroll 0% 0% transparent;">是一个用于通过绑定到诸如<font face="DejaVu Serif, serif">array</font></span><font face="DejaVu Serif, serif"></font><span style="background: none repeat scroll 0% 0% transparent;">和<font face="DejaVu Serif, serif">Cursor</font></span><font face="DejaVu Serif, serif"></font><span style="background: none repeat scroll 0% 0% transparent;">等<font face="DejaVu Serif, serif">data
source</font></span><font face="DejaVu Serif, serif"></font><span style="background: none repeat scroll 0% 0% transparent;">并陈列一系列<font face="DejaVu Serif, serif">item</font></span><font face="DejaVu Serif, serif"></font><span style="background: none repeat scroll 0% 0% transparent;">，当用户选中一个<font face="DejaVu Serif, serif">item</font></span><font face="DejaVu Serif, serif"></font><span style="background: none repeat scroll 0% 0% transparent;">的时候，会传出<font face="DejaVu Serif, serif">event
handler</font></span><font face="DejaVu Serif, serif"></font><span style="background: none repeat scroll 0% 0% transparent;">。</span></font></p>
<p style="margin-bottom: 0cm;"><font color="#008000"><font face="DejaVu Serif, serif"><span style="background: none repeat scroll 0% 0% transparent;">ListActivity</span></font><span style="background: none repeat scroll 0% 0% transparent;">拥有一个可以绑定到<font face="DejaVu Serif, serif">data
source</font></span><font face="DejaVu Serif, serif"></font><span style="background: none repeat scroll 0% 0% transparent;">（尤其指带有<font face="DejaVu Serif, serif">query
result</font></span><font face="DejaVu Serif, serif"></font><span style="background: none repeat scroll 0% 0% transparent;">的<font face="DejaVu Serif, serif">array</font></span><font face="DejaVu Serif, serif"></font><span style="background: none repeat scroll 0% 0% transparent;">或<font face="DejaVu Serif, serif">Cursor</font></span><font face="DejaVu Serif, serif"></font><span style="background: none repeat scroll 0% 0% transparent;">）的<font face="DejaVu Serif, serif">ListView</font></span><font face="DejaVu Serif, serif"></font><span style="background: none repeat scroll 0% 0% transparent;">对象。
<font face="DejaVu Serif, serif">Binding,screen layout</font></span><font face="DejaVu Serif, serif"></font><span style="background: none repeat scroll 0% 0% transparent;">和<font face="DejaVu Serif, serif">row</font></span><font face="DejaVu Serif, serif"></font><span style="background: none repeat scroll 0% 0% transparent;">在下面讨论。</span></font></p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">1</font>）<font face="DejaVu Serif, serif">screen
layout </font>
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">ListActivity
has a default layout that consists of a single, full-screen list in
the center of the screen. However, if you desire, you can customize
the screen layout by setting your own view layout with
setContentView() in onCreate(). To do this, your own view MUST
contain a ListView object with the id "@android:id/list"
(or list if it's in code) </font>
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">Optionally,
your custom view can contain another view object of any type to
display when the list view is empty. This "empty list"
notifier must have an id "android:empty". Note that when an
empty view is present, the list view will be hidden when there is no
data to display. </font>
</p>
<p style="margin-bottom: 0cm;"><font color="#008000"><font face="DejaVu Serif, serif">ListActivity</font>有唯一一个充满整个<font face="DejaVu Serif, serif">screen</font>并位于<font face="DejaVu Serif, serif">screen</font>正中的<font face="DejaVu Serif, serif">list</font>的默认<font face="DejaVu Serif, serif">layout</font>。当然，如果你想的话，你可以用<font face="DejaVu Serif, serif">onCreate()</font>里面的<font face="DejaVu Serif, serif">setContentView()</font>来透过设置自己的<font face="DejaVu Serif, serif">layout</font>来定制这个<font face="DejaVu Serif, serif">screen
layout</font>。如果你要这样做，你定制的<font face="DejaVu Serif, serif">layout</font>里面务必要包含一个<font face="DejaVu Serif, serif">ListView</font>的<font face="DejaVu Serif, serif">object</font>，而且它的<font face="DejaVu Serif, serif">id</font>必须为&#8220;<font face="DejaVu Serif, serif">@android:id/list&#8221;</font>（括号里面没看懂什么意思）</font></p>
<p style="margin-bottom: 0cm;"><font color="#008000">另外，你定制的<font face="DejaVu Serif, serif">view</font>可以包含另外一个任何种类的<font face="DejaVu Serif, serif">view</font>对象，当<font face="DejaVu Serif, serif">list
view</font>为空的时候它会显现出来，类似地，它的<font face="DejaVu Serif, serif">id</font>必须为&#8220;<font face="DejaVu Serif, serif">@id/android:empty&#8221;</font>。</font></p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">2</font>）<font face="DejaVu Serif, serif">row
layout</font>：</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">You
can specify the layout of individual rows in the list. You do this by
specifying a layout resource in the ListAdapter object hosted by the
activity (the ListAdapter binds the ListView to the data; more on
this later). </font>
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">A
ListAdapter constructor takes a parameter that specifies a layout
resource for each row. It also has two additional parameters that let
you specify which data field to associate with which object in the
row layout resource. These two parameters are typically parallel
arrays. </font>
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">Android
provides some standard row layout resources. These are in the
R.layout class, and have names such as simple_list_item_1,
simple_list_item_2, and two_line_list_item. The following layout XML
is the source for the resource two_line_list_item, which displays two
data fields,one above the other, for each list row. </font>
</p>
<p style="margin-bottom: 0cm;"><font color="#008000">你可以制定<font face="DejaVu Serif, serif">list</font>每一个单独的<font face="DejaVu Serif, serif">row</font>的<font face="DejaVu Serif, serif">layout</font>。当你这样做时，你可以通过设置<font face="DejaVu Serif, serif">ListAdapter</font>对象来决定使用哪个<font face="DejaVu Serif, serif">layout
resource</font>。一个<font face="DejaVu Serif, serif">ListAdapter</font>的<font face="DejaVu Serif, serif">constructor</font>至少设置一个<font face="DejaVu Serif, serif">parameter</font>来设定<font face="DejaVu Serif, serif">layout
resource</font>。同时它有着两个<font face="DejaVu Serif, serif">additonal
parameter</font>让你制定哪些<font face="DejaVu Serif, serif">data
field</font>应该对应到哪个<font face="DejaVu Serif, serif">layout
resource</font>中的对象中去。这两个<font face="DejaVu Serif, serif">parameter</font>通常是<font face="DejaVu Serif, serif">parallel
array</font>（我理解成一一对应的两个数组，比如说<font face="DejaVu Serif, serif">key-value
pair</font>就是一种<font face="DejaVu Serif, serif">parallel
array</font>，具体参看下面样例代码中的<font face="DejaVu Serif, serif">SimpleAdapter</font>的定义过程，共五个参数，其中第三个时上面说的哪个设定<font face="DejaVu Serif, serif">layout
resource</font>的参数，最后两个就是那对<font face="DejaVu Serif, serif">parallel
array</font>了）</font></p>
<p style="margin-bottom: 0cm;"><font color="#008000"><font face="DejaVu Serif, serif">android</font>提供了一些标准的<font face="DejaVu Serif, serif">row
layout resource</font>。他们在<font face="DejaVu Serif, serif">R.layout</font>类里面，比如说：</font></p>
<p style="margin-bottom: 0cm;"><font color="#008000"><font face="DejaVu Serif, serif">Simple_list_item_1
</font>每项有一个<font face="DejaVu Serif, serif">TextView</font></font></p>
<p style="margin-bottom: 0cm;"><font color="#008000"><font face="DejaVu Serif, serif">Simple_list_item_2
</font>每项有两个<font face="DejaVu Serif, serif">TextView</font></font></p>
<p style="margin-bottom: 0cm;"><font color="#008000"><font face="DejaVu Serif, serif">Simple_list_item_checked
</font>带<font face="DejaVu Serif, serif">CheckView</font>的项</font></p>
<p style="margin-bottom: 0cm;"><font color="#008000"><font face="DejaVu Serif, serif">Simple_list_item_multiple_choise
</font>每项有一个<font face="DejaVu Serif, serif">TextView</font>并可以多选</font></p>
<p style="margin-bottom: 0cm;"><font color="#008000"><font face="DejaVu Serif, serif">Simple_list_item_single_choice
</font>每项有一个<font face="DejaVu Serif, serif">TextView</font>，但只能进行单选。</font></p>
<p style="margin-bottom: 0cm;">（<font face="DejaVu Serif, serif">3</font>）<font face="DejaVu Serif, serif">Binding
to data</font>：</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">You
bind the ListActivity's ListView object to data using a class that
implements the <code class="western"><a>ListAdapter</a></code>
interface. Android provides two standard list adapters: <code class="western"><a>SimpleAdapter</a></code>
for static data (Maps), and <code class="western"><a>SimpleCursorAdapter</a></code>
for Cursor query results. </font>
</p>
<p><font color="#008000">你需要通过一个<font face="DejaVu Serif, serif">implement</font>了<font face="DejaVu Serif, serif">ListAdapter</font>接口的类来把<font face="DejaVu Serif, serif">ListActivity</font>的<font face="DejaVu Serif, serif">ListView
object</font>绑定到<font face="DejaVu Serif, serif">data</font>上。<font face="DejaVu Serif, serif">Android</font>提供了两个标准的<font face="DejaVu Serif, serif">list
adapters:</font>针对<font face="DejaVu Serif, serif">static
data(maps)</font>使用的<font face="DejaVu Serif, serif">Simple
Adapter</font>和针对<font face="DejaVu Serif, serif">Cursor query
result</font>使用的<font face="DejaVu Serif, serif">SimpleCursorAdapter</font>。</font></p>
<p><br />
<br />
</p>
<p style="margin-bottom: 0cm;">二，小零碎：</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">android:drawSelectorOnTop
</font>默认为<font face="DejaVu Serif, serif">false</font>，而且为<font face="DejaVu Serif, serif">true</font>的时候颜色会把选项菜单中的字给盖住。（原文是：<font face="DejaVu Serif, serif">When
set to true, the selector will be drawn over the selected item.
Otherwise the selector is drawn behind the selected item.</font>）</p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;">三，个人的理解和样例代码<font face="DejaVu Serif, serif">:</font></p>
<p style="margin-bottom: 0cm;">简单来说，<font face="DejaVu Serif, serif">ListActivity</font>就是一个捆绑了<font face="DejaVu Serif, serif">List</font>的<font face="DejaVu Serif, serif">Activity</font>，但是他比普通的<font face="DejaVu Serif, serif">Activity</font>上外加一个<font face="DejaVu Serif, serif">List</font>的建立过程要简单得多。</p>
<p style="margin-bottom: 0cm;">普通的<font face="DejaVu Serif, serif">Activity</font>要添加<font face="DejaVu Serif, serif">List</font>，首先要在<font face="DejaVu Serif, serif">layout</font>文件中定义一个<font face="DejaVu Serif, serif">ListView</font>，但<font face="DejaVu Serif, serif">ListActivity</font>里面则可以连<font face="DejaVu Serif, serif">setContentView()</font>都不用写，<font face="DejaVu Serif, serif">Android</font>系统会自动给你分配一个占据全屏幕的<font face="DejaVu Serif, serif">List</font>对象。另外，在设置<font face="DejaVu Serif, serif">ListAdapter</font>的时候，系统提供了一些默认的布局（比如<font face="DejaVu Serif, serif">simple_list_item_2</font>等），可以省去自定义<font face="DejaVu Serif, serif">List</font>布局的功夫（当然有必要的时候也是可以自定义<font face="DejaVu Serif, serif">List</font>的布局的）。</p>
<p style="margin-bottom: 0cm;">总体来说，<font face="DejaVu Serif, serif">ListActivity</font>就是为了简化<font face="DejaVu Serif, serif">List</font>建立过程而提供的一个<font face="DejaVu Serif, serif">Activity</font>的子类。</p>
<p style="margin-bottom: 0cm;">下面是我自己测试的代码。（没有<font face="DejaVu Serif, serif">layout</font>文件因为用不上～）</p>
<br />
<div style="background-color: rgb(238, 238, 238); font-size: 13px; border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; width: 98%;"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0, 0, 255);">package</span><span style="color: rgb(0, 0, 0);">&nbsp;level0.test.listActivity;<br />
<br />
</span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">&nbsp;java.util.ArrayList;<br />
</span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">&nbsp;java.util.HashMap;<br />
</span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">&nbsp;java.util.List;<br />
<br />
</span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">&nbsp;android.app.ListActivity;<br />
</span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">&nbsp;android.os.Bundle;<br />
</span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">&nbsp;android.view.View;<br />
</span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">&nbsp;android.widget.ListView;<br />
</span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">&nbsp;android.widget.SimpleAdapter;<br />
</span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">&nbsp;android.widget.Toast;<br />
<br />
</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">&nbsp;ListActivityTest&nbsp;</span><span style="color: rgb(0, 0, 255);">extends</span><span style="color: rgb(0, 0, 0);">&nbsp;ListActivity&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">final</span><span style="color: rgb(0, 0, 0);">&nbsp;String&nbsp;HashMap&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);">&nbsp;Called&nbsp;when&nbsp;the&nbsp;activity&nbsp;is&nbsp;first&nbsp;created.&nbsp;</span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />
&nbsp;&nbsp;&nbsp;&nbsp;@Override<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;onCreate(Bundle&nbsp;savedInstanceState)&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">super</span><span style="color: rgb(0, 0, 0);">.onCreate(savedInstanceState);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;使用了ListActivity自带的的布局，可以注释掉setContentView()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;setContentView(R.layout.main);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;定义存放列表的数据结构</span><span style="color: rgb(0, 128, 0);"><br />
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">HashMap</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">String,&nbsp;String</span><span style="color: rgb(0, 0, 0);">&gt;&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;items&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;ArrayList</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">HashMap</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">String,&nbsp;String</span><span style="color: rgb(0, 0, 0);">&gt;&gt;</span><span style="color: rgb(0, 0, 0);">();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HashMap</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">String,&nbsp;String</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;user1&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;HashMap</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">String,&nbsp;String</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HashMap</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">String,&nbsp;String</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;user2&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;HashMap</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">String,&nbsp;String</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HashMap</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">String,&nbsp;String</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">&nbsp;user3&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;HashMap</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">String,&nbsp;String</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);">();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;为每个数据项填充数据</span><span style="color: rgb(0, 128, 0);"><br />
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user1.put(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">user_name</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">level0</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user1.put(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">user_phone</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">135******</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user2.put(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">user_name</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">lisi</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user2.put(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">user_phone</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">1356*****</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user3.put(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">user_name</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">wangwu</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user3.put(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">user_phone</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">13544****</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;把数据项添加到列表当中</span><span style="color: rgb(0, 128, 0);"><br />
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;items.add(user1);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;items.add(user2);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;items.add(user3);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;添加一个SimpleAdapter,其中第三个参数直接利用了android中提供的一个显示在一列中显示两个TextView的布局，第五个参数是android提供的TextView的id</span><span style="color: rgb(0, 128, 0);"><br />
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SimpleAdapter&nbsp;adapter&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;SimpleAdapter(</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">,&nbsp;items,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android.R.layout.simple_list_item_2,&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;String[]&nbsp;{<br />
&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 style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">user_name</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,&nbsp;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">user_phone</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;},&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">[]&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;android.R.id.text1,&nbsp;android.R.id.text2&nbsp;});<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;为ListActivity设置Adapter</span><span style="color: rgb(0, 128, 0);"><br />
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setListAdapter(adapter);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;@Override<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">protected</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;onListItemClick(ListView&nbsp;l,&nbsp;View&nbsp;v,&nbsp;</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">&nbsp;position,&nbsp;</span><span style="color: rgb(0, 0, 255);">long</span><span style="color: rgb(0, 0, 0);">&nbsp;id)&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;TODO&nbsp;Auto-generated&nbsp;method&nbsp;stub</span><span style="color: rgb(0, 128, 0);"><br />
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Toast.makeText(</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">,&nbsp;id&nbsp;</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">:</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">((HashMap)getListView().getItemAtPosition(position)).get(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">user_name</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">).toString(),&nbsp;Toast.LENGTH_SHORT).show();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">super</span><span style="color: rgb(0, 0, 0);">.onListItemClick(l,&nbsp;v,&nbsp;position,&nbsp;id);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
}</span></div>
<p style="margin-bottom: 0cm;" align="LEFT"><br />
</p>
<p style="margin-bottom: 0cm;" align="LEFT"><font color="#000000"><font face="Monospace"><font size="2">能力有限，先写到这里了。</font></font></font></p>
<p style="margin-bottom: 0cm;" align="LEFT"><font color="#000000"><font face="Monospace"><font size="2">另外可以参看文章：</font></font></font></p>
<p style="margin-bottom: 0cm;" align="LEFT"><font color="#000000"><font face="Monospace"><font size="2">http://blog.csdn.net/xlfb8057/archive/2008/09/04/2880347.aspx</font></font></font></p>
<img src ="http://www.blogjava.net/level0/aggbug/341552.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/level0/" target="_blank">level0</a> 2010-12-26 10:47 <a href="http://www.blogjava.net/level0/articles/341552.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android Log</title><link>http://www.blogjava.net/level0/articles/341058.html</link><dc:creator>level0</dc:creator><author>level0</author><pubDate>Sat, 18 Dec 2010 06:45:00 GMT</pubDate><guid>http://www.blogjava.net/level0/articles/341058.html</guid><wfw:comment>http://www.blogjava.net/level0/comments/341058.html</wfw:comment><comments>http://www.blogjava.net/level0/articles/341058.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/level0/comments/commentRss/341058.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/level0/services/trackbacks/341058.html</trackback:ping><description><![CDATA[<style type="text/css">p { margin-bottom: 0.21cm; }code.cjk { font-family: "DejaVu Sans",monospace; }code.ctl { font-family: "DejaVu Sans Mono",monospace; }a:link {  }strong { font-style: italic; font-weight: normal; }</style>
<p style="margin-bottom: 0cm;"><font color="#000080"><font face="DejaVu Serif, serif">2010.12.03</font></font></p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif"><font color="#ff0000">@Override</font></font><font color="#ff0000">：</font>在子类实现父类的方法时，在前一行添加<font face="DejaVu Serif, serif">@Override</font>标记是很有好处的：当敲错方法名的时候，编译器会报错。</p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font color="#000080"><font face="DejaVu Serif, serif">2010.12.05</font></font></p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">AVD
for Android Virtual Device</font></p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">SDK
for Software Development Kit</font></p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">API
for Application Programming Interface</font></p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">GUI
for Graphical User Interface</font></p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font color="#000080"><font face="DejaVu Serif, serif">2010.12.09</font></font></p>
<p style="margin-bottom: 0cm;">一，关于<font face="DejaVu Serif, serif">activity:</font></p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font>，属于<font face="DejaVu Serif, serif">android.app.Activity</font>包</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font>，<font face="DejaVu Serif, serif">An
activity is a single, focused thing that the user can do.
</font>活动是一个单独的，能获得焦点的能与用户进行交互<font face="DejaVu Serif, serif">(interact)</font>的东西。</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">3</font>，<font face="DejaVu Serif, serif"><code class="western"><a>onCreate(Bundle)</a></code>
is where you initialize your activity. Most importantly, here you
will usually call <code class="western"><a>setContentView(int)</a></code>
with a layout resource defining your UI, and using <code class="western"><a>findViewById(int)</a></code>
to retrieve the widgets in that UI that you need to interact with
programmatically. </font>
</p>
<p style="margin-bottom: 0cm;">其中一个常用（必需？）的方法是<font face="DejaVu Serif, serif">onCreate(Bundle)</font>，在其中会调用到<font face="DejaVu Serif, serif">setContentView(int)</font>链接向<font face="DejaVu Serif, serif">res</font>中的<font face="DejaVu Serif, serif">layout</font>或者其他资源（<font face="DejaVu Serif, serif">xml</font>？）。另外，<font face="DejaVu Serif, serif">findViewById(int)</font>用于检索<font face="DejaVu Serif, serif">UI</font>中的组件（专业名词为<font face="DejaVu Serif, serif">component</font>，也可通称为<font face="DejaVu Serif, serif">widget</font>），进行建立触发器（监听器？<font face="DejaVu Serif, serif">listener</font>）等操作。</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">4</font>，<font face="DejaVu Serif, serif">To
be of use with <code class="western"><a>Context.startActivity()</a></code>,
all activity classes must have a corresponding <code class="western"><a>&lt;activity&gt;</a></code>
declaration in their package's
<code class="western">AndroidManifest.xml</code>.</font>建立每个活动之后需要在<font face="DejaVu Serif, serif">AndroidManifest.xml</font>中注册才能使用。</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">5</font>，<font face="DejaVu Serif, serif"><a>onCreateOptionsMenu</a>(<a>Menu</a>
menu) </font>
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">Initialize
the contents of the Activity's standard options
menu.</font>用于建立标准的选项菜单（<font face="DejaVu Serif, serif">android</font>上按下<font face="DejaVu Serif, serif">menu</font>键进入）<font face="DejaVu Serif, serif">public
boolean onOptionsItemSelected </font>
</p>
<p><font face="DejaVu Serif, serif">This hook is called whenever an
item in your options menu is selected.</font>用于进一步建立选项菜单的内部选项</p>
<p style="margin-bottom: 0cm;">二，<font face="DejaVu Serif, serif">What
is the differences and conections among Activity, Intent and View?</font></p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1</font>，<font face="DejaVu Serif, serif">An
activity is a single, focused thing that the user can do.
</font>活动是一个单独的，能获得焦点的能与用户进行交互<font face="DejaVu Serif, serif">(interact)</font>的东西。</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2</font>，<font face="DejaVu Serif, serif">An
intent is an abstract description of an operation to be performed. It
can be used with <code class="western"><a>startActivity</a></code>
to launch an <code class="western"><a>Activity</a></code><code class="western">.</code>
</font>
</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">Intent</font>是一个抽象的描诉（意图做什么事？目前来说我不太理解这个概念），它可以用形如<font face="DejaVu Serif, serif">startActivity(new
Intent(this, **))</font>的语句来启动一个新的<font face="DejaVu Serif, serif">Activity</font>。</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">3</font>，<font face="DejaVu Serif, serif">View</font>：<font face="DejaVu Serif, serif">This
class represents the basic building block for user interface
components. A View occupies a rectangular area on the screen and is
responsible for drawing and event handling. View is the base class
for <strong>widgets</strong>, which are used to create interactive UI
components (buttons, text fields, etc.)</font></p>
<p style="margin-bottom: 0cm;">我暂时的理解是&#8220;视图&#8221;。<font face="DejaVu Serif, serif">View</font>是<font face="DejaVu Serif, serif">UI</font>的最基本创建版块，占领一个方形区域用于绘制图形和放置事件的句柄——组件的基本类，常用于建立可交互组件（按钮，文本域）。</p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">4</font>，目前关于这三者的关系，我理解是：<font face="DejaVu Serif, serif">application</font>的基本单位应该是<font face="DejaVu Serif, serif">Activity——application</font>由许许多多的彼此独立<font face="DejaVu Serif, serif">Activity</font>构成。<font face="DejaVu Serif, serif">Activity</font>的一个重要特性是它要跟用户产生交互，而交互的关键在于<font face="DejaVu Serif, serif">Acitivity</font>里面有许许多多的<font face="DejaVu Serif, serif">view</font>，<font face="DejaVu Serif, serif">view</font>不仅仅是一个静态的视图，我们可以在<font face="DejaVu Serif, serif">View</font>上注册诸如按钮，对话框等交互组件。在<font face="DejaVu Serif, serif">Activity</font>中我们经常利用<font face="DejaVu Serif, serif">findViewById</font>来查找对应的交互组件<font face="DejaVu Serif, serif">(</font>或者说交互组件就是<font face="DejaVu Serif, serif">view</font>自身？<font face="DejaVu Serif, serif">)</font>来添加<font face="DejaVu Serif, serif">listener.</font>那么<font face="DejaVu Serif, serif">Intent</font>又是什么？<font face="DejaVu Serif, serif">Intent</font>我翻译成意图，目前我只感觉它是一个由一个<font face="DejaVu Serif, serif">Activity</font>跳转到另一个<font face="DejaVu Serif, serif">Activity</font>的媒介——因为有了这样那样的&#8220;意图&#8221;，所以我们需要从目前的<font face="DejaVu Serif, serif">Activity</font>跳到另外一个才能相应那个&#8220;意图&#8221;——目前我是这样理解的，不过按文档来说<font face="DejaVu Serif, serif">Intent</font>有着更加深厚的意义，那个以后遇上再说吧。</p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;">三，<font face="DejaVu Serif, serif">label</font>和<font face="DejaVu Serif, serif">title</font>的差别？</p>
<p style="margin-bottom: 0cm;">都是在<font face="DejaVu Serif, serif">R</font>下的<font face="DejaVu Serif, serif">@string</font>里面的条目，目前来说感觉<font face="DejaVu Serif, serif">label</font>是一个短标记后面一般不跟其他东西，<font face="DejaVu Serif, serif">title</font>下会跟着其他内容（<font face="DejaVu Serif, serif">text</font>，<font face="DejaVu Serif, serif">label</font>什么的都可以。）</p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm;"><font color="#800000"><strong>四，最后要提到的一点，</strong><font face="DejaVu Serif, serif"><strong>Eclipse</strong></font><strong>的包的自动补全功能</strong><font face="DejaVu Serif, serif"><strong>Ctrl+Shift+O</strong></font><strong>。（一定要记住阿，相当好用）</strong></font></p>
<p style="margin-bottom: 0cm;"><br />
</p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000080"><font face="DejaVu Serif, serif">2010.12.10</font></font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">一，<font face="DejaVu Serif, serif">magin</font>和<font face="DejaVu Serif, serif">padding</font>的差别？</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">对于一个<font face="DejaVu Serif, serif">border</font>（边框）来说，<font face="DejaVu Serif, serif">margin</font>是外边距，<font face="DejaVu Serif, serif">padding</font>是内边距。</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"></p>
<p style="margin-bottom: 0cm; font-weight: normal;"></p>
<p style="margin-bottom: 0cm; font-weight: normal;"></p>
<p style="margin-bottom: 0cm; font-weight: normal;"></p>
<p style="margin-bottom: 0cm; font-weight: normal;"></p>
<p style="margin-bottom: 0cm; font-weight: normal;"></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000080"><font face="DejaVu Serif, serif">2010.11.12</font></font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">一，什么是<font face="DejaVu Serif, serif">context</font>？</font></p>
<p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif"><font color="#000000"><span style="font-weight: normal;">context</span></font></font><font color="#000000"><span style="font-weight: normal;">：</span></font><font face="DejaVu Serif, serif">Interface
to global information about an application environment. This is an
abstract class whose implementation is provided by the Android
system. It allows access to application-specific resources and
classes, as well as up-calls for application-level operations such as
launching activities, broadcasting and receiving intents, etc. </font>
</p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000"><font face="DejaVu Serif, serif">context</font>（语境？）是一个关于应用环境的全局信息的接口，由<font face="DejaVu Serif, serif">android</font>系统来负责实现。它可以进行启动<font face="DejaVu Serif, serif">Activity</font>和接收<font face="DejaVu Serif, serif">intents</font>等操作。</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><br />
</p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">二<font face="DejaVu Serif, serif">,</font>关于<font face="DejaVu Serif, serif">view</font>的一点细节</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">不要在<font face="DejaVu Serif, serif">view</font>的构造函数中试图使用<font face="DejaVu Serif, serif">view</font>的高度和宽度，那是因为那时候<font face="DejaVu Serif, serif">Android</font>并不知道视图的大小（当时宽度和高度都默认为<font face="DejaVu Serif, serif">0</font>）——<font face="DejaVu Serif, serif">Android</font>在布局阶段才会计算宽度和高度——那是在构造函数被调用之后而任何对象被绘制之前。</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">在视图的宽度和高度已知后，会通知<font face="DejaVu Serif, serif">onSizeChanged</font>方法，因而可以在其中引用<font face="DejaVu Serif, serif">view</font>的宽度和高度。另一种引用的方法是在诸如<font face="DejaVu Serif, serif">onDraw()</font>的方法中用<font face="DejaVu Serif, serif">getWidth()</font>与<font face="DejaVu Serif, serif">getHeight()</font>获取宽度和高度。</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><br />
</p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000080"><font face="DejaVu Serif, serif">2010.11.14</font></font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">一，关于<font face="DejaVu Serif, serif">Eclipse</font>的一些常用快捷键</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000"><font face="DejaVu Serif, serif">ctrl+shift+o
</font>自动补全包，相当好用</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000"><font face="DejaVu Serif, serif">ctrl+1
</font>简易提示改成错误的方法</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000"><font face="DejaVu Serif, serif">alt+/
</font>自动补全参数名，类名，方法名，巨好用</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000"><font face="DejaVu Serif, serif">ctrl+/
</font>给选中范围注释，再按一次为消除注释</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000"><font face="DejaVu Serif, serif">ctrl+o
</font>显示类当前继承结构</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000"><font face="DejaVu Serif, serif">ctrl+shift+f
</font>给选中内容进行自动排版。</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">二，实现<font face="DejaVu Serif, serif">[Android</font>开发视频教学<font face="DejaVu Serif, serif">].01_05_Activity</font>和<font face="DejaVu Serif, serif">Intent
</font>的代码时遇到的错误：</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">（<font face="DejaVu Serif, serif">1</font>）错误：<font face="DejaVu Serif, serif">R.id.one</font>是一个<font face="DejaVu Serif, serif">EditText</font>，我企图直接用<font face="DejaVu Serif, serif">String
one = getText(R.id.one).toString()</font>来直接把它的值赋予给<font face="DejaVu Serif, serif">one</font>。结果是弹出异常。</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">改正办法：正确代码如下：<font face="DejaVu Serif, serif">EditText
textOne = (EditText)findViewById(R.id.one);String one =
textOne.getText().toString();</font></font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">即先建立一个名为<font face="DejaVu Serif, serif">textOne</font>的<font face="DejaVu Serif, serif">EditText</font>，然后用<font face="DejaVu Serif, serif">getText()</font>方法得到它的内容。</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">（<font face="DejaVu Serif, serif">2</font>）错误：企图直接用<font face="DejaVu Serif, serif">setText(answer)</font>方法来直接输入<font face="DejaVu Serif, serif">answer</font>（<font face="DejaVu Serif, serif">ansser</font>是个<font face="DejaVu Serif, serif">int</font>变量）。</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">改正办法：代码改写成<font face="DejaVu Serif, serif">setText(answer
+
&#8220;&#8221;);</font>即可（根据<font face="DejaVu Serif, serif">Java</font>语法，<font face="DejaVu Serif, serif">int+String</font>类型自动转换成<font face="DejaVu Serif, serif">String</font>类型，补充一句是<font face="DejaVu Serif, serif">setText()</font>里面的内容只能是<font face="DejaVu Serif, serif">String</font>类型的东西）</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><br />
</p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000080"><font face="DejaVu Serif, serif">2010.11.15</font></font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">一，关于<font face="DejaVu Serif, serif">Bundle</font>：</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000"><font face="DejaVu Serif, serif">A
mapping from String values to various Parcelable types. </font></font>
</p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">一个从字符值到各种可打包类型的映射。</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">（目前就在<font face="DejaVu Serif, serif">onCreate(Bundle
savedInstanceState)</font>看到过，理解成一捆数据么？）</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><br />
</p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">二，<font face="DejaVu Serif, serif">this</font>和<font face="DejaVu Serif, serif">super</font>指针用法：</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000"><font face="DejaVu Serif, serif">this</font>概述：在生成一个对象的时候，系统会自动生成一个指向<font color="#800000">对象</font>的<font face="DejaVu Serif, serif">this</font>指针，所以<font face="DejaVu Serif, serif">this</font>指针是不会指向静态类的。</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">用法：（<font face="DejaVu Serif, serif">1</font>）在方法中存在该对象的同名实例变量，需要用&#8220;<font face="DejaVu Serif, serif">this.</font>实例变量名&#8221;来引用实例变量。</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">
（<font face="DejaVu Serif, serif">2</font>）在方法中需要应用到<font color="#800000">对象</font>自身的时候，用
&#8221;类名<font face="DejaVu Serif, serif">.this&#8220;</font>来进行引用。</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">
（<font face="DejaVu Serif, serif">3</font>）可以在构造函数中直接用&#8220;<font face="DejaVu Serif, serif">this(</font>参数名<font face="DejaVu Serif, serif">)&#8221;
</font>来调用自身构造函数，有时候可以简化代码。</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000"><font face="DejaVu Serif, serif">super</font>概述：在继承关系中，<font face="DejaVu Serif, serif">super</font>指向子类的<font color="#800000">父类</font>。</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">用法：（<font face="DejaVu Serif, serif">1</font>）在子类中引用父类的同名实例变量时，用&#8220;<font face="DejaVu Serif, serif">super.</font>实例变量名&#8221;引用父类的变量。</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">
（<font face="DejaVu Serif, serif">2</font>）在子类的构造函数中用<font face="DejaVu Serif, serif">super.</font>构造函数名<font face="DejaVu Serif, serif">()</font>调用父类的构造函数。（只能放在构造函数的第一行）</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">
（<font face="DejaVu Serif, serif">3</font>）在子类中引用父类的同名方法时，用&#8220;<font face="DejaVu Serif, serif">super.</font>方法名<font face="DejaVu Serif, serif">(</font>参数名<font face="DejaVu Serif, serif">)&#8221;</font>引用父类的方法。</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><br />
</p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000">三，<font face="DejaVu Serif, serif">Eclipse</font>中又两个个好用的快捷键：</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000"><font face="DejaVu Serif, serif">F3</font>：快速定位当前选中的自定义方法，自定义变量名的原出处。</font></p>
<p style="margin-bottom: 0cm; font-weight: normal;"><font color="#000000"><font face="DejaVu Serif, serif">F4</font>：快速展开选中类的继承层次。</font></p>
<img src ="http://www.blogjava.net/level0/aggbug/341058.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/level0/" target="_blank">level0</a> 2010-12-18 14:45 <a href="http://www.blogjava.net/level0/articles/341058.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>