<?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>cap&#039;n webb &#187; Java</title>
	<atom:link href="http://blog.dataich.com/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dataich.com</link>
	<description>almost all things about it</description>
	<lastBuildDate>Thu, 12 Jan 2012 03:38:00 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Android &#8211; サンプルアプリケーションの概要</title>
		<link>http://blog.dataich.com/2008/06/09/android-%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%81%ae%e6%a6%82%e8%a6%81/</link>
		<comments>http://blog.dataich.com/2008/06/09/android-%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%81%ae%e6%a6%82%e8%a6%81/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 06:14:00 +0000</pubDate>
		<dc:creator>dataich</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://dataich.s15.coreserver.jp/blog/2008/06/09/android-%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%81%ae%e6%a6%82%e8%a6%81/</guid>
		<description><![CDATA[前回作成したサンプルアプリケーションのディレクトリ構成を見てみると、下記のようになっています。 anroid src com lancard tasklist R.java TaskList.java res drawa [...]]]></description>
			<content:encoded><![CDATA[<p>前回作成したサンプルアプリケーションのディレクトリ構成を見てみると、下記のようになっています。<br />
anroid</p>
<ul>
<li> src
<ul>
<li> com
<ul>
<li> lancard
<ul>
<li> tasklist
<ul>
<li> R.java</li>
<li> TaskList.java</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li> res
<ul>
<li>
<ul>
<li> drawable
<ul>
<li> icon.pnh</li>
</ul>
</li>
<li> layout
<ul>
<li> main.xml</li>
</ul>
</li>
<li> values
<ul>
<li> strings.xml</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li> AndroidManifest.xml</li>
</ul>
<p>まずは、resから見ていきます。</p>
<p><strong>drawable</strong><br />
ここには、アプリケーションで使用する画像ファイルを配置します。</p>
<p><strong>layout</strong><br />
ここには、アプリケーションで使用する画面定義ファイルを配置します。<br />
デフォルトではmain.xmlが作成されていますが、アプリケーションによっては複数の画面を使用したい場合もあります。<br />
その場合には、ここにxmlを追加することになります。</p>
<p><strong>values</strong><br />
ここには、アプリケーションで使用する、文字列定義等のファイルを配置します。デフォルトではstrings.xmlが用意されていますが、他にもarrays.xml、colors.xmlなどを配置できます。</p>
<p>次に、srcを見てみます。</p>
<h4>R.java</h4>
<p>res配下の各種定義ファイルに書かれているリソースにアクセスするためのクラスで、自動生成され、直接編集してはいけません。<br />
ソースを見てみると下記のようになっているかと思います。<br />
res配下のディレクトリ構成と同じように、クラスが作成されているかと思います。<br />
res/drawable/icon.pnfの場合は、R.drawable.iconとなっています。<br />
res/strings.xmlの場合は、xml 内のresources/stringの属性app_nameが読み込まれています。<br />
これを使用して、各種リソースにアクセスすることになります。</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.lancard.tasklist</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">class</span> R <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">class</span> attr <span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">class</span> drawable <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> icon<span style="color: #339933;">=</span>0x7f020000<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">class</span> layout <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> main<span style="color: #339933;">=</span>0x7f030000<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">class</span> string <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> app_name<span style="color: #339933;">=</span>0x7f040000<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h4>TaskList.java</h4>
<p>メインクラスになります。ソースを見てみます。<br />
基本的にメインクラスは、android.app.Activityを継承して作成します。<br />
もちろん、 Activityクラスを継承した別クラスも用意されています。<br />
onCreateメソッドは、アプリケーション実行時に最初に呼ばれるメソッドで、メソッドの最初で親クラスのonCreateメソッドを呼び出す必要があります。<br />
その後、setContentView(R.layout.main)として、メイン画面のビュー定義をセットしています。</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.lancard.tasklist</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.app.Activity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.os.Bundle</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TaskList <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/** Called when the activity is first created. */</span>
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span>Bundle icicle<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span><span style="color: #009900;">&#40;</span>icicle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        setContentView<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">main</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>次に、AndroidManifest.xmlを見てみます。<br />
アプリケーション全体の設定ファイルになっており、デフォルトでは下記のようになっているかと思います。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;manifest</span> <span style="color: #000066;">xmlns:android</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/res/android&quot;</span> <span style="color: #000066;">package</span>=<span style="color: #ff0000;">&quot;com.lancard.tasklist&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;application</span> <span style="color: #000066;">android:icon</span>=<span style="color: #ff0000;">&quot;@drawable/icon&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;activity</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;.TaskList&quot;</span> <span style="color: #000066;">android:label</span>=<span style="color: #ff0000;">&quot;@string/app_name&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;intent-filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.intent.action.MAIN&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;category</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.intent.category.LAUNCHER&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/intent-filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/activity<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/manifest<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>3行目の android:icon=&#8221;@drawable/icon&#8221; は、R.drawable.iconを指定していることになります。</p>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://blog.dataich.com/2008/06/09/android-%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%81%ae%e6%a6%82%e8%a6%81/&via=dataich&text=Android - サンプルアプリケーションの概要&related=:&lang=en&count=vertical" class="twitter-share-button" onclick="pageTracker._trackPageview('/outgoing/twitter.com/share?url=http_//blog.dataich.com/2008/06/09/android-_e3_82_b5_e3_83_b3_e3_83_97_e3_83_ab_e3_82_a2_e3_83_97_e3_83_aa_e3_82_b1_e3_83_bc_e3_82_b7_e3_83_a7_e3_83_b3_e3_81_ae_e6_a6_82_e8_a6_81/_via=dataich_text=Android_-_related=_lang=en_count=vertical&amp;referer=');">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://blog.dataich.com/2008/06/09/android-%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%81%ae%e6%a6%82%e8%a6%81/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tugboat</title>
		<link>http://blog.dataich.com/2007/08/30/tugboat/</link>
		<comments>http://blog.dataich.com/2007/08/30/tugboat/#comments</comments>
		<pubDate>Thu, 30 Aug 2007 03:20:00 +0000</pubDate>
		<dc:creator>dataich</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Life Hack]]></category>
		<category><![CDATA[Seasar]]></category>

		<guid isPermaLink="false">http://dataich.s15.coreserver.jp/blog/2007/08/30/tugboat/</guid>
		<description><![CDATA[seasarで構築されたオープンソースプロジェクト管理システム。 環境構築は簡単。 他のメンバーがどんなタスクを抱えているか、今何をやっているかが管理できる。 なにはともあれ、インターフェースがとても良い。 そのうち本格 [...]]]></description>
			<content:encoded><![CDATA[<p>seasarで構築されたオープンソースプロジェクト管理システム。</p>
<p>環境構築は簡単。<br />
他のメンバーがどんなタスクを抱えているか、今何をやっているかが管理できる。<br />
なにはともあれ、インターフェースがとても良い。<br />
そのうち本格的に導入するつもり。（案が通れば）</p>
<p><a class="wpGallery" href="http://tugboat-gtd.sandbox.seasar.org/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/tugboat-gtd.sandbox.seasar.org/?referer=');">Tugboat.GTD</a></p>
<div style="float: right; margin-left: 10px;"><a href="http://twitter.com/share?url=http://blog.dataich.com/2007/08/30/tugboat/&via=dataich&text=tugboat&related=:&lang=en&count=vertical" class="twitter-share-button" onclick="pageTracker._trackPageview('/outgoing/twitter.com/share?url=http_//blog.dataich.com/2007/08/30/tugboat/_via=dataich_text=tugboat_related=_lang=en_count=vertical&amp;referer=');">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>]]></content:encoded>
			<wfw:commentRss>http://blog.dataich.com/2007/08/30/tugboat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

