<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Marshal&#039;s Blog &#187; 管理实务</title>
	<atom:link href="http://marshal.easymorse.com/archives/category/%e7%ae%a1%e7%90%86%e5%ae%9e%e5%8a%a1/feed" rel="self" type="application/rss+xml" />
	<link>http://marshal.easymorse.com</link>
	<description>It&#039;s swap of marshal&#039;s memory.</description>
	<lastBuildDate>Tue, 07 Sep 2010 08:15:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>在ListView中实现多种视条目</title>
		<link>http://marshal.easymorse.com/archives/3080</link>
		<comments>http://marshal.easymorse.com/archives/3080#comments</comments>
		<pubDate>Fri, 13 Aug 2010 03:08:53 +0000</pubDate>
		<dc:creator>Marshal</dc:creator>
				<category><![CDATA[管理实务]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[android layout]]></category>
		<category><![CDATA[android ui]]></category>
		<category><![CDATA[android view]]></category>

		<guid isPermaLink="false">http://marshal.easymorse.com/archives/3080</guid>
		<description><![CDATA[在imdb中有这样的界面：
 
画红框的部分其实都是ListView中的条目，不过它们是不同的View。
 
实现了一个类似的界面效果：
 
其中日期标题部分视图布局：
&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62;      &#60;LinearLayout xmlns:android=&#34;http://schemas.android.com/apk/res/android&#34;       &#160;&#160;&#160; android:orientation=&#34;vertical&#34; android:layout_width=&#34;fill_parent&#34;       &#160;&#160;&#160; android:layout_height=&#34;10dip&#34; android:background=&#34;@drawable/section_background&#34;&#62;       &#160;&#160;&#160; &#60;TextView android:id=&#34;@+id/section_title&#34;       &#160;&#160;&#160;&#160;&#160;&#160;&#160; android:layout_width=&#34;fill_parent&#34; android:layout_height=&#34;match_parent&#34; /&#62;      [...]]]></description>
			<content:encoded><![CDATA[<p>在imdb中有这样的界面：</p>
<p><a href="http://marshal.easymorse.com/wp-content/uploads/2010/08/image26.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://marshal.easymorse.com/wp-content/uploads/2010/08/image_thumb26.png" width="205" height="294" /></a> </p>
<p>画红框的部分其实都是ListView中的条目，不过它们是不同的View。</p>
<p> <span id="more-3080"></span>
<p>实现了一个类似的界面效果：</p>
<p><a href="http://marshal.easymorse.com/wp-content/uploads/2010/08/image27.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://marshal.easymorse.com/wp-content/uploads/2010/08/image_thumb27.png" width="204" height="310" /></a> </p>
<p>其中日期标题部分视图布局：</p>
<blockquote><p>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;      <br />&lt;LinearLayout xmlns:android=&quot;<a href="http://schemas.android.com/apk/res/android&quot;">http://schemas.android.com/apk/res/android&quot;</a>       <br />&#160;&#160;&#160; android:orientation=&quot;vertical&quot; android:layout_width=&quot;fill_parent&quot;       <br />&#160;&#160;&#160; android:layout_height=&quot;10dip&quot; android:background=&quot;@drawable/section_background&quot;&gt;       <br />&#160;&#160;&#160; &lt;TextView android:id=&quot;@+id/section_title&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;match_parent&quot; /&gt;       <br />&lt;/LinearLayout&gt;</p>
<p>&#160;</p>
</blockquote>
<p>带图片的条目布局部分：</p>
<blockquote><p>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;      <br />&lt;LinearLayout xmlns:android=&quot;<a href="http://schemas.android.com/apk/res/android&quot;">http://schemas.android.com/apk/res/android&quot;</a>       <br />&#160;&#160;&#160; android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;wrap_content&quot;       <br />&#160;&#160;&#160; android:orientation=&quot;horizontal&quot; &gt;       <br />&#160;&#160;&#160; &lt;ImageView android:id=&quot;@+id/image&quot; android:src=&quot;@drawable/p&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; /&gt;       <br />&#160;&#160;&#160; &lt;TextView android:id=&quot;@+id/title&quot; android:layout_width=&quot;wrap_content&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; android:layout_height=&quot;wrap_content&quot; /&gt;       <br />&lt;/LinearLayout&gt;</p>
</blockquote>
<p>问题在于，如何在ListView中既有标题条目又有内容条目。</p>
<p>这里用到了设计模式中的Iterator模式。在java代码中示例有Iterator，可以迭代ArrayList，HashSet等不同的数据结构对象。</p>
<p>这里设计了一个类族：</p>
<p><a href="http://marshal.easymorse.com/wp-content/uploads/2010/08/image28.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://marshal.easymorse.com/wp-content/uploads/2010/08/image_thumb28.png" width="467" height="232" /></a> </p>
<p>ListElement是接口：</p>
<blockquote><p>package com.easymorse.listview.customer; </p>
<p>import android.content.Context;      <br />import android.view.LayoutInflater;       <br />import android.view.View; </p>
<p>public interface ListElement {      <br />&#160;&#160;&#160; public int getLayoutId(); </p>
<p>&#160;&#160;&#160; public boolean isClickable(); </p>
<p>&#160;&#160;&#160; public View getViewForListElement(LayoutInflater layoutInflater,      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Context context, View view);       <br />}</p>
</blockquote>
<p>其中:</p>
<ul>
<li>getLayoutId()返回布局的值； </li>
<li>isClickable()返回是否可点击； </li>
<li>getViewForListElement()返回视图对象。 </li>
</ul>
<p>这个接口有两个实现：</p>
<ul>
<li>SectionListElement，用于实现标题条目； </li>
<li>ContentListElement，用于实现内容条目。 </li>
</ul>
<p>见SectionListElement代码：</p>
<blockquote><p>package com.easymorse.listview.customer; </p>
<p>import android.content.Context;      <br />import android.view.LayoutInflater;       <br />import android.view.View;       <br />import android.widget.LinearLayout;       <br />import android.widget.TextView; </p>
<p>public class SectionListElement implements ListElement { </p>
<p>&#160;&#160;&#160; private String text; </p>
<p>&#160;&#160;&#160; public void setText(String text) {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.text = text;       <br />&#160;&#160;&#160; } </p>
<p>&#160;&#160;&#160; @Override      <br />&#160;&#160;&#160; public int getLayoutId() {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return R.layout.section;       <br />&#160;&#160;&#160; } </p>
<p>&#160;&#160;&#160; @Override      <br />&#160;&#160;&#160; public boolean isClickable() {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return false;       <br />&#160;&#160;&#160; } </p>
<p>&#160;&#160;&#160; @Override      <br />&#160;&#160;&#160; public View getViewForListElement(LayoutInflater layoutInflater,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Context context, View view) {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; LinearLayout layout = (LinearLayout) layoutInflater.inflate(getLayoutId(), null);       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; TextView textView=(TextView) layout.findViewById(R.id.section_title);       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; textView.setText(text);       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return layout;       <br />&#160;&#160;&#160; } </p>
<p>}</p>
<p>&#160;</p>
</blockquote>
<p>见ContentListElement代码：</p>
<blockquote><p>package com.easymorse.listview.customer; </p>
<p>import android.content.Context;      <br />import android.view.LayoutInflater;       <br />import android.view.View;       <br />import android.widget.LinearLayout;       <br />import android.widget.TextView; </p>
<p>public class ContentListElement implements ListElement { </p>
<p>&#160;&#160;&#160; private String title;      <br />&#160;&#160;&#160; public void setTitle(String title) {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.title = title;       <br />&#160;&#160;&#160; } </p>
<p>&#160;&#160;&#160; @Override      <br />&#160;&#160;&#160; public int getLayoutId() {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return R.layout.item;       <br />&#160;&#160;&#160; } </p>
<p>&#160;&#160;&#160; @Override      <br />&#160;&#160;&#160; public View getViewForListElement(LayoutInflater layoutInflater,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Context context, View view) {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; LinearLayout layout = (LinearLayout) layoutInflater.inflate(       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; getLayoutId(), null);       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; TextView textView = (TextView) layout.findViewById(R.id.title);       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; textView.setText(title);       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return layout;       <br />&#160;&#160;&#160; } </p>
<p>&#160;&#160;&#160; @Override      <br />&#160;&#160;&#160; public boolean isClickable() {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return true;       <br />&#160;&#160;&#160; } </p>
<p>}</p>
</blockquote>
<p>ListView需要ListAdapter的实现。在这里是直接集成BaseAdapter来实现的。用于交给ListView生成出列表。代码：</p>
<blockquote><p>package com.easymorse.listview.customer; </p>
<p>import java.util.ArrayList;     <br />import java.util.List; </p>
<p>import android.content.Context;     <br />import android.view.LayoutInflater;      <br />import android.view.View;      <br />import android.view.ViewGroup;      <br />import android.widget.BaseAdapter; </p>
<p>public class CustomerListAdapter extends BaseAdapter { </p>
<p>&#160;&#160;&#160; private Context context; </p>
<p>&#160;&#160;&#160; protected ArrayList&lt;ListElement&gt; resultList; </p>
<p>&#160;&#160;&#160; private LayoutInflater layoutInflater; </p>
<p>&#160;&#160;&#160; public CustomerListAdapter(Context context) {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; super();      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.context = context;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.layoutInflater = (LayoutInflater) context      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .getSystemService(&quot;layout_inflater&quot;);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.resultList = new ArrayList&lt;ListElement&gt;();      <br />&#160;&#160;&#160; } </p>
<p>&#160;&#160;&#160; @Override     <br />&#160;&#160;&#160; public int getCount() {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return this.resultList.size();      <br />&#160;&#160;&#160; } </p>
<p>&#160;&#160;&#160; @Override     <br />&#160;&#160;&#160; public Object getItem(int position) {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return this.resultList.get(position);      <br />&#160;&#160;&#160; } </p>
<p>&#160;&#160;&#160; @Override     <br />&#160;&#160;&#160; public long getItemId(int position) {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return position;      <br />&#160;&#160;&#160; } </p>
<p>&#160;&#160;&#160; @Override     <br />&#160;&#160;&#160; public View getView(int position, View view, ViewGroup parent) {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return this.resultList.get(position).getViewForListElement(      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; layoutInflater, context, view);      <br />&#160;&#160;&#160; } </p>
<p>&#160;&#160;&#160; public void addList(List&lt;ListElement&gt; elements) {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.resultList.addAll(elements);      <br />&#160;&#160;&#160; } </p>
<p>&#160;&#160;&#160; @Override     <br />&#160;&#160;&#160; public boolean isEnabled(int position) {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return this.resultList.get(position).isClickable();      <br />&#160;&#160;&#160; } </p>
<p>&#160;&#160;&#160; public void addSectionHeaderItem(String text) {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; SectionListElement element = new SectionListElement();      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; element.setText(text);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.resultList.add(element);      <br />&#160;&#160;&#160; }      <br />}</p>
</blockquote>
<p>在Activity中创建CustomerListAdapter以及设置它的代码部分：</p>
<blockquote><p>CustomerListAdapter adapter = new CustomerListAdapter(this); </p>
<p>adapter.addSectionHeaderItem(&quot;2002-3-1&quot;); </p>
<p>ArrayList&lt;ListElement&gt; elements = new ArrayList&lt;ListElement&gt;();     <br />for (int i = 0; i &lt; 5; i++) {      <br />&#160;&#160;&#160; ContentListElement element = new ContentListElement();      <br />&#160;&#160;&#160; element.setTitle(&quot;哈利波特第&quot; + (i+1) + &quot;集&quot;);      <br />&#160;&#160;&#160; elements.add(element);      <br />}      <br />adapter.addList(elements); </p>
<p>adapter.addSectionHeaderItem(&quot;2002-2-2&quot;); </p>
<p>elements = new ArrayList&lt;ListElement&gt;();     <br />for (int i = 0; i &lt; 3; i++) {      <br />&#160;&#160;&#160; ContentListElement element = new ContentListElement();      <br />&#160;&#160;&#160; element.setTitle(&quot;指环王第&quot; + (i+1) + &quot;集&quot;);      <br />&#160;&#160;&#160; elements.add(element);      <br />}      <br />adapter.addList(elements); </p>
<p>this.setListAdapter(adapter);</p>
</blockquote>
<p>这里ListActivity，还需要注意两件事情，Activity要继承ListActivity。另外，在layout中：</p>
<blockquote><p><a href="http://easymorse.googlecode.com/svn/tags/customer.listview-0.1.0/">http://easymorse.googlecode.com/svn/tags/customer.listview-0.1.0/</a></p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://marshal.easymorse.com/archives/3080/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>简化的项目管理阶段划分</title>
		<link>http://marshal.easymorse.com/archives/303</link>
		<comments>http://marshal.easymorse.com/archives/303#comments</comments>
		<pubDate>Tue, 31 Jan 2006 16:00:02 +0000</pubDate>
		<dc:creator>Marshal</dc:creator>
				<category><![CDATA[管理实务]]></category>
		<category><![CDATA[UML]]></category>
		<category><![CDATA[项目管理笔记]]></category>

		<guid isPermaLink="false">http://marshal.easymorse.com/blog/archives/303</guid>
		<description><![CDATA[项目管理使用什么样的过程？挑选人才有个&#8220;人才适用&#8221;原则，项目管理也类似，够用即可。
 
基本过程可总结为如下阶段：

启动：认识和确认项目要做哪些事情，在此期间应确认项目负责人（包括授权他筹备和组建项目团队）。在军事上类似首长根据宏观战局分析下作战决心。 
计划：制订详细计划过程，包括：任务列表、资源分配、时间表、预算、沟通计划、风险计划和变化控制流程，这些需要实施者拿出时间细化而不是匆匆而为。提交的计划得到上级领导批准，该计划就是所谓的项目基线(project baseline)。从军事上类似首长作战决心交由参谋部和作战部制定详细作战计划（包括绘制详细的作战单位的行军路线和序列）。 
控制：检查和控制执行是按照计划进行，确认是否按时、是否预算以内、是否符合项目规范和开发需求等，并向上级领导提交控制报告。从军事上就是指挥各单位作战； 
关闭：向客户提交可交付的产品，总结项目中的经验教训，奖励项目团队和庆祝项目成功。类似军事上的作战总结会和庆功会。 

上述阶段是最简化的了，无法再合并。许多管理过程都是在此基础上进一步细化，会有更多的阶段/步骤。
如果用uml状态图表示：
 
需要注意的是：

控制阶段的依据是计划，这和管理学中的计划和控制阶段的作用一致； 
当执行中发现实际和计划有出入，应该通过控制来修改计划，而后再执行； 
控制阶段一分为二：执行和控制两部分，其中执行本身和管理无关，小项目的管理者要注意角色的切换和大局观，因为往往也要参与执行； 
关闭阶段往往被忽略，一个优秀的团队需要在关闭阶段通过总结获得凝聚力、共识和提高。 

]]></description>
			<content:encoded><![CDATA[<p>项目管理使用什么样的过程？挑选人才有个&#8220;人才适用&#8221;原则，项目管理也类似，够用即可。</p>
<p> <span id="more-303"></span>
<p>基本过程可总结为如下阶段：</p>
<ol>
<li>启动：认识和确认项目要做哪些事情，在此期间应确认项目负责人（包括授权他筹备和组建项目团队）。在军事上类似首长根据宏观战局分析下作战决心。 </li>
<li>计划：制订详细计划过程，包括：任务列表、资源分配、时间表、预算、沟通计划、风险计划和变化控制流程，这些需要实施者拿出时间细化而不是匆匆而为。提交的计划得到上级领导批准，该计划就是所谓的<em>项目基线(project baseline)</em>。从军事上类似首长作战决心交由参谋部和作战部制定详细作战计划（包括绘制详细的作战单位的行军路线和序列）。 </li>
<li>控制：检查和控制执行是按照计划进行，确认是否按时、是否预算以内、是否符合项目规范和开发需求等，并向上级领导提交控制报告。从军事上就是指挥各单位作战； </li>
<li>关闭：向客户提交可交付的产品，总结项目中的经验教训，奖励项目团队和庆祝项目成功。类似军事上的作战总结会和庆功会。 </li>
</ol>
<p>上述阶段是最简化的了，无法再合并。许多管理过程都是在此基础上进一步细化，会有更多的阶段/步骤。</p>
<p>如果用uml状态图表示：</p>
<p><a href="http://marshal.easymorse.com/wp-content/uploads/2008/10/pm.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="286" alt="pm" src="http://marshal.easymorse.com/wp-content/uploads/2008/10/pm-thumb.jpg" width="354" border="0" /></a> </p>
<p>需要注意的是：</p>
<ul>
<li>控制阶段的依据是计划，这和管理学中的<em>计划</em>和<em>控制</em>阶段的作用一致； </li>
<li>当执行中发现实际和计划有出入，应该通过控制来修改计划，而后再执行； </li>
<li>控制阶段一分为二：执行和控制两部分，其中执行本身和管理无关，小项目的管理者要注意角色的切换和大局观，因为往往也要参与执行； </li>
<li>关闭阶段往往被忽略，一个优秀的团队需要在关闭阶段通过总结获得凝聚力、共识和提高。 </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://marshal.easymorse.com/archives/303/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
