<?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>@blog.justoneplanet.info &#187; コンピューター言語</title>
	<atom:link href="http://blog.justoneplanet.info/category/computer-language/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.justoneplanet.info</link>
	<description>日々勉強</description>
	<lastBuildDate>Sat, 04 Feb 2012 11:10:47 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHPで不正な閉じタグを見つける</title>
		<link>http://blog.justoneplanet.info/2012/02/04/php%e3%81%a7%e4%b8%8d%e6%ad%a3%e3%81%aa%e9%96%89%e3%81%98%e3%82%bf%e3%82%b0%e3%82%92%e8%a6%8b%e3%81%a4%e3%81%91%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2012/02/04/php%e3%81%a7%e4%b8%8d%e6%ad%a3%e3%81%aa%e9%96%89%e3%81%98%e3%82%bf%e3%82%b0%e3%82%92%e8%a6%8b%e3%81%a4%e3%81%91%e3%82%8b/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 11:10:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=5000</guid>
		<description><![CDATA[ループは1回にできると思うけどまぁとりあえず。 &#60;?php $str = &#60;&#60;&#60;EOD &#60;html&#62; &#60;body&#62; &#60;center&#62; &#60;form acti [...]]]></description>
			<content:encoded><![CDATA[<p>ループは1回にできると思うけどまぁとりあえず。</p>
<pre class="brush: php;">
&lt;?php
$str = &lt;&lt;&lt;EOD
&lt;html&gt;
&lt;body&gt;
&lt;center&gt;
&lt;form action=&quot;confirm.php&quot; method=&quot;get&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;name&quot;&gt;&lt;br&gt;
&lt;input type=&quot;submit&quot; value=&quot;submit&quot;&gt;
&lt;/center&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
EOD;

preg_match_all(&quot;/&lt;.*?&gt;/&quot;, $str, $matches);
//var_dump($matches);
$ary = array();
$stack = array();

foreach ($matches[0] as $key =&gt; $value) {
    array_push($ary, $value);
}

foreach ($ary as $key =&gt; $value) {
    if (preg_match(&quot;/&lt;\/([a-zA-Z]+)/&quot;, $value, $tag)) {
#        echo &quot;$value\n&quot;;
#        var_dump($tag[1]);
        $isFoundClose = false;
        foreach ($ary as $k =&gt; $v) {
            if (preg_match(&quot;/&lt;{$tag[1]}/&quot;, $v)) {
#                echo &quot;match\n&quot;;
                $isFoundClose = true;
                array_splice($ary, $k, $key - $k);
                break;
            }
        }
        if (!$isFoundClose) {
            echo &quot;error:$value\n&quot;;
        }
    }
    else {

    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2012/02/04/php%e3%81%a7%e4%b8%8d%e6%ad%a3%e3%81%aa%e9%96%89%e3%81%98%e3%82%bf%e3%82%b0%e3%82%92%e8%a6%8b%e3%81%a4%e3%81%91%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UITextViewの高さを可変にする</title>
		<link>http://blog.justoneplanet.info/2012/01/29/uitextview%e3%81%ae%e9%ab%98%e3%81%95%e3%82%92%e5%8f%af%e5%a4%89%e3%81%ab%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2012/01/29/uitextview%e3%81%ae%e9%ab%98%e3%81%95%e3%82%92%e5%8f%af%e5%a4%89%e3%81%ab%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 17:17:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4983</guid>
		<description><![CDATA[編集可能なUITextViewを使用するときに入力内容にあわせてUITextViewの高さを変えたい時がある。 ■コード 以下のようにUITextViewを定義する。 textview = [[UITextView al [...]]]></description>
			<content:encoded><![CDATA[<p>編集可能なUITextViewを使用するときに入力内容にあわせてUITextViewの高さを変えたい時がある。</p>
<h3>■コード</h3>
<p>以下のようにUITextViewを定義する。</p>
<pre class="brush: cpp;">
textview = [[UITextView alloc] init];
[textview setFrame:CGRectMake(0, 0, 100, 50)];
[textview setEditable:YES];
[textview setDelegate:self];
</pre>
<p>以下のようにcontentSizeを使用する。</p>
<pre class="brush: cpp;">
-(void)textViewDidChange:(UITextView *)textView {
    CGRect f = textview.frame;
    f.size.height = textview.contentSize.height;
    textview.frame = f;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2012/01/29/uitextview%e3%81%ae%e9%ab%98%e3%81%95%e3%82%92%e5%8f%af%e5%a4%89%e3%81%ab%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>android-support-v4.jarを使ったプロジェクトのテストをする</title>
		<link>http://blog.justoneplanet.info/2012/01/16/android-support-v4-jar%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88%e3%82%92%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2012/01/16/android-support-v4-jar%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88%e3%82%92%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 16:38:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[テスト]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4948</guid>
		<description><![CDATA[テスト対象のプロジェクトにおいて以下の操作をする。 propaties &#62; Java Build Path &#62; Order and Export &#62; android-support-v4.jarにチェッ [...]]]></description>
			<content:encoded><![CDATA[<p>テスト対象のプロジェクトにおいて以下の操作をする。</p>
<p>propaties &gt; Java Build Path &gt; Order and Export &gt; android-support-v4.jarにチェックを入れる。</p>
<h4>.classpath</h4>
<p>以下のようにexported属性が付加されている。</p>
<pre class="brush: xml;">
&lt;classpathentry exported=&quot;true&quot; kind=&quot;lib&quot; path=&quot;libs/android-support-v4.jar&quot;/&gt;
</pre>
<h4>悪い例</h4>
<p>テストプロジェクトにandroid-support-v4.jarをインポートすると以下のようなエラーがでる。</p>
<pre class="brush: plain;">
java.lang.RuntimeException: Exception during suite construction
at android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests.testSuiteConstructionFailed(TestSuiteBuilder.java:239)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
at android.test.suitebuilder.TestMethod.instantiateTest(TestMethod.java:87)
at android.test.suitebuilder.TestMethod.createTest(TestMethod.java:73)
at android.test.suitebuilder.TestSuiteBuilder.addTest(TestSuiteBuilder.java:263)
at android.test.suitebuilder.TestSuiteBuilder.build(TestSuiteBuilder.java:185)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:373)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3285)
at android.app.ActivityThread.access$2200(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:987)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3728)
at java.lang.reflect.Method.invokeNative(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
</pre>
<section class="kakomi">
<h4>参考</h4>
<ul>
<li><a href="http://dtmilano.blogspot.com/2009/12/android-testing-external-libraries.html">Android Testing: External libraries</a></li>
</ul>
</section>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2012/01/16/android-support-v4-jar%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%9f%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88%e3%82%92%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>androidでレンダリング後のViewのサイズを取得する</title>
		<link>http://blog.justoneplanet.info/2012/01/15/android%e3%81%a7%e3%83%ac%e3%83%b3%e3%83%80%e3%83%aa%e3%83%b3%e3%82%b0%e5%be%8c%e3%81%aeview%e3%81%ae%e3%82%b5%e3%82%a4%e3%82%ba%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2012/01/15/android%e3%81%a7%e3%83%ac%e3%83%b3%e3%83%80%e3%83%aa%e3%83%b3%e3%82%b0%e5%be%8c%e3%81%aeview%e3%81%ae%e3%82%b5%e3%82%a4%e3%82%ba%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 08:51:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[View]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4944</guid>
		<description><![CDATA[onClickなどのユーザイベント実行時に取得するならば以下の方法で取得ができる。 mView.setOnClickListener(new View.OnClickListener(){ @Override publi [...]]]></description>
			<content:encoded><![CDATA[<p>onClickなどのユーザイベント実行時に取得するならば以下の方法で取得ができる。</p>
<pre class="brush: java;">
mView.setOnClickListener(new View.OnClickListener(){
    @Override
    public void onClick(View v) {
        int width = v.getWidth();
        int height = v.getHeight();
    }
});
</pre>
<p>これを利用して以下のようにすると正しく取得できない。</p>
<pre class="brush: java;">
@Override
public void onCreate(Bundle savedInstanceState) {
    // ...
    int width = mView.getWidth();// 0
    int height = mView.getHeight();// 0
}
</pre>
<p>onCreate, onStart, onResumeではレンダリングが終了していないためサイズが0となる。</p>
<h3>■解決策</h3>
<p>以下のようにViewTreeObserverを利用することでレンダリング後のサイズを取得することができる。</p>
<pre class="brush: java;">
@Override
public void onCreate(Bundle savedInstanceState) {
    // ...
    ViewTreeObserver viewTreeObserver = mView.getViewTreeObserver();
    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            int width = mView.getWidth();
            int height = mView.getHeight();
        }
    });
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2012/01/15/android%e3%81%a7%e3%83%ac%e3%83%b3%e3%83%80%e3%83%aa%e3%83%b3%e3%82%b0%e5%be%8c%e3%81%aeview%e3%81%ae%e3%82%b5%e3%82%a4%e3%82%ba%e3%82%92%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CentOSにHaskellを入れる</title>
		<link>http://blog.justoneplanet.info/2012/01/09/centos%e3%81%abhaskell%e3%82%92%e5%85%a5%e3%82%8c%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2012/01/09/centos%e3%81%abhaskell%e3%82%92%e5%85%a5%e3%82%8c%e3%82%8b/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 05:47:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Haskell]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4917</guid>
		<description><![CDATA[めも。 ■ghc wget http://www.haskell.org/ghc/dist/7.2.2/ghc-7.2.2-x86_64-unknown-linux.tar.bz2 tar xvfj ghc-7.2.2- [...]]]></description>
			<content:encoded><![CDATA[<p>めも。</p>
<h3>■ghc</h3>
<pre class="brush: bash;">
wget http://www.haskell.org/ghc/dist/7.2.2/ghc-7.2.2-x86_64-unknown-linux.tar.bz2
tar xvfj ghc-7.2.2-x86_64-unknown-linux.tar.bz2
cd ghc-7.2.2
./configure --prefix=/usr/local/haskell/ghc/7.2.2
make install
export PATH=/usr/local/haskell/ghc/7.2.2/bin:$PATH
</pre>
<h4>コーディング</h4>
<pre class="brush: bash;">
vim hello.hs
</pre>
<pre class="brush: plain;">
main = putStrLn &quot;Hello World&quot;
</pre>
<h4>実行</h4>
<p>以下のコマンドでコンパイルと実行が同時にできる。</p>
<pre class="brush: bash;">
ghc -e main hello.hs
</pre>
<p>もしくは以下のコマンドを実行する。</p>
<pre class="brush: bash;">
ghc --make hello.hs
./hello
</pre>
<section class="kakomi">
<h4>インタプリタ</h4>
<p>以下のコマンドで起動する。</p>
<pre class="brush: bash;">
ghci
</pre>
<p>以下のようにしてインストールできる。</p>
<pre class="brush: bash;">
Prelude&gt; putStrLn &quot;Hello World&quot;
Hello World
</pre>
<p>以下のようにしてインタプリタを終了できる。</p>
<pre class="brush: bash;">
&lt;ctrl&gt;+D
</pre>
</section>
<h4>エラー</h4>
<pre class="brush: bash;">
&lt;command line&gt;: can't load .so/.DLL for: libgmp.so (libgmp.so: cannot open shared object file: No such file or directory)
</pre>
<p>以下のコマンドで解決できる。</p>
<pre class="brush: bash;">
cd /usr/lib64
ln -s libgmp.so.3 libgmp.so
</pre>
<section class="kakomi">
<h4>参考</h4>
<ul>
<li><a href="http://www.haskell.org/ghc/">The Glasgow Haskell Compiler</a></li>
</ul>
</section>
<h3>■hugs</h3>
<p>インタプリタ。ghciもあるので必要がないと思われる。</p>
<pre class="brush: bash;">
wget http://cvs.haskell.org/Hugs/downloads/2006-09/hugs98-Sep2006.tar.gz
tar xvzf hugs98-Sep2006.tar.gz
cd hugs98-Sep2006
./configure
make
make install
</pre>
<h4>開始</h4>
<pre class="brush: bash;">
hugs
</pre>
<h4>終了</h4>
<pre class="brush: bash;">
&lt;ctrl&gt;+D
</pre>
<h4>Hello World</h4>
<pre class="brush: bash;">
Hugs&gt; putStrLn &quot;Hello World&quot;
Hello World
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2012/01/09/centos%e3%81%abhaskell%e3%82%92%e5%85%a5%e3%82%8c%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>androidでActivityが切り替わるときのアニメーションを変える</title>
		<link>http://blog.justoneplanet.info/2012/01/09/android%e3%81%a7activity%e3%81%8c%e5%88%87%e3%82%8a%e6%9b%bf%e3%82%8f%e3%82%8b%e3%81%a8%e3%81%8d%e3%81%ae%e3%82%a2%e3%83%8b%e3%83%a1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88/</link>
		<comments>http://blog.justoneplanet.info/2012/01/09/android%e3%81%a7activity%e3%81%8c%e5%88%87%e3%82%8a%e6%9b%bf%e3%82%8f%e3%82%8b%e3%81%a8%e3%81%8d%e3%81%ae%e3%82%a2%e3%83%8b%e3%83%a1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 15:36:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4914</guid>
		<description><![CDATA[activityが切り替わるときにアニメーションをさせたくなくなった。 ■実装 res/values/style.xml 以下のようにテーマを定義する。 &#60;resource&#62; &#60;style name=&#038; [...]]]></description>
			<content:encoded><![CDATA[<p>activityが切り替わるときにアニメーションをさせたくなくなった。</p>
<h3>■実装</h3>
<h4>res/values/style.xml</h4>
<p>以下のようにテーマを定義する。</p>
<pre class="brush: xml;">
&lt;resource&gt;
    &lt;style name=&quot;NoAnimationTheme&quot; parent=&quot;android:Theme&quot;&gt;
        &lt;item name=&quot;android:windowAnimationStyle&quot;&gt;@style/Animation.Activity&lt;/item&gt;
    &lt;/style&gt;
    &lt;style name=&quot;Animation.Activity&quot; parent=&quot;android:Animation.Activity&quot;&gt;
        &lt;item name=&quot;android:activityOpenEnterAnimation&quot;&gt;@anim/activity_open_enter&lt;/item&gt;
        &lt;item name=&quot;android:activityOpenExitAnimation&quot;&gt;@anim/activity_open_exit&lt;/item&gt;
        &lt;item name=&quot;android:activityCloseEnterAnimation&quot;&gt;@anim/activity_close_enter&lt;/item&gt;
        &lt;item name=&quot;android:activityCloseExitAnimation&quot;&gt;@anim/activity_close_exit&lt;/item&gt;
    &lt;/style&gt;
&lt;/resource&gt;
</pre>
<section class="kakomi">
<h4>anim/activity_open_enter.xml</h4>
<p>startActivityで開くActivityのanimation。</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;set xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:interpolator=&quot;@android:anim/accelerate_interpolator&quot;&gt;
    &lt;translate
        android:fromXDelta=&quot;100%&quot;
        android:toXDelta=&quot;0%&quot;
        android:duration=&quot;0&quot;
        android:fillAfter=&quot;true&quot;
        android:fillEnabled=&quot;true&quot;/&gt;
&lt;/set&gt;
</pre>
<h4>anim/activity_open_exit.xml</h4>
<p>startActivityで閉じるActivityのanimation。</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;set xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:interpolator=&quot;@android:anim/accelerate_interpolator&quot;&gt;
    &lt;translate
        android:fromXDelta=&quot;0%&quot;
        android:toXDelta=&quot;-100%&quot;
        android:duration=&quot;0&quot;
        android:fillAfter=&quot;true&quot;
        android:fillEnabled=&quot;true&quot;/&gt;
&lt;/set&gt;
</pre>
<h4>anim/activity_close_exit.xml</h4>
<p>finishで閉じるActivityのanimation。</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;set xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:interpolator=&quot;@android:anim/accelerate_interpolator&quot;&gt;
    &lt;translate
        android:fromXDelta=&quot;0%&quot;
        android:toXDelta=&quot;100%&quot;
        android:duration=&quot;0&quot;
        android:fillAfter=&quot;true&quot;
        android:fillEnabled=&quot;true&quot;/&gt;
&lt;/set&gt;
</pre>
<h4>anim/activity_close_open.xml</h4>
<p>finishで開くActivityのanimation。</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;set xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:interpolator=&quot;@android:anim/accelerate_interpolator&quot;&gt;
    &lt;translate
        android:fromXDelta=&quot;-100%&quot;
        android:toXDelta=&quot;0%&quot;
        android:duration=&quot;0&quot;
        android:fillAfter=&quot;true&quot;
        android:fillEnabled=&quot;true&quot;/&gt;
&lt;/set&gt;
</pre>
<h5>参考</h5>
<p>上述の内容などは以下のような参考サイトに情報がある。</p>
<ul>
<li><a href="http://www.adamrocker.com/blog/289/activity_open_close_animation.html">ActivityのOpenとCloseをアニメーションさせる</a></li>
<li><a href="http://www.atmarkit.co.jp/fsmart/articles/android21/02.html">アニメーションでAndroidに独創的な画面エフェクトを</a></li>
<li><a href="http://stackoverflow.com/questions/7997753/is-it-possible-to-do-this-android-screen-animation-with-a-viewpager">Is it possible to do this Android screen animation with a ViewPager?</a></li>
<li><a href="http://stackoverflow.com/questions/3925355/android-fadeout-animation-for-splash-screen">Android &#8211; Fadeout animation for splash screen</a></li>
</ul>
</section>
<h4>AndroidManifest.xml</h4>
<h5>アプリケーション全体に適用する</h5>
<p>以下のようにapplicationタグに記述することでアプリケーション全体に変更したアニメーションを適用できる。</p>
<pre class="brush: xml;">
&lt;application
    android:icon=&quot;@drawable/icon&quot;
    android:label=&quot;@string/app_name&quot;
    android:theme=&quot;@style/NoAnimationTheme&quot;&gt;
</pre>
<h5>アクティビティに適用する</h5>
<p>以下のようにactivityタグに記述することで単一のアクティビティにのみ変更したアニメーションを適用できる。</p>
<pre class="brush: xml;">
&lt;activity
    android:label=&quot;@string/app_name&quot;
    android:name=&quot;.MainActivity&quot;&gt;
&lt;/activity&gt;
</pre>
<h3>■応用</h3>
<p>上述の方法だと特定の条件下でのみアニメーションを変えるといったことができない。条件によってanimationを変えたい場合は、以下のようにすることで対応できる。</p>
<pre class="brush: java;">
public class MainActivity extends Activity {
    /**
     * 起動時に実行される
     */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setTheme(R.style.NoAnimationTheme);// super.onCreateの前に実行する必要がある
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2012/01/09/android%e3%81%a7activity%e3%81%8c%e5%88%87%e3%82%8a%e6%9b%bf%e3%82%8f%e3%82%8b%e3%81%a8%e3%81%8d%e3%81%ae%e3%82%a2%e3%83%8b%e3%83%a1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92%e5%a4%89%e3%81%88/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>androidでギャラリーと連携する</title>
		<link>http://blog.justoneplanet.info/2012/01/08/android%e3%81%a7%e3%82%ae%e3%83%a3%e3%83%a9%e3%83%aa%e3%83%bc%e3%81%a8%e9%80%a3%e6%90%ba%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2012/01/08/android%e3%81%a7%e3%82%ae%e3%83%a3%e3%83%a9%e3%83%aa%e3%83%bc%e3%81%a8%e9%80%a3%e6%90%ba%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 11:38:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[インテント]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4912</guid>
		<description><![CDATA[■実装 ギャラリーの起動 以下のようにすることで（画像データに選択肢を絞って）ギャラリーアプリを起動することができる。 Intent intent = new Intent(); intent.setType(&#038;quot [...]]]></description>
			<content:encoded><![CDATA[<h3>■実装</h3>
<h4>ギャラリーの起動</h4>
<p>以下のようにすることで（画像データに選択肢を絞って）ギャラリーアプリを起動することができる。</p>
<pre class="brush: java;">
Intent intent = new Intent();
intent.setType(&quot;image/*&quot;);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, REQUESTCODE);
</pre>
<h4>ギャラリーからデータを受け取る</h4>
<pre class="brush: java;">
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUESTCODE &amp;&amp; resultCode == RESULT_OK) {
        //data.getData();//ギャラリーで選択したファイルのuriが格納されている
    }
}
</pre>
<section class="kakomi">
<h4>uriからpathの文字列を取得</h4>
<p>以下のようにすることでuriからpathの文字列を取得することができる。</p>
<pre class="brush: java;">
private final String getPathFromUri(Uri uri) {
    String[] projection = { MediaStore.Images.Media.DATA };
    Cursor cursor = managedQuery(uri, projection, null, null, null);
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
}
</pre>
<h5>参考</h5>
<ul>
<li><a href="http://stackoverflow.com/questions/3401579/get-filename-and-path-from-uri-from-mediastore">Get filename and path from uri from mediastore</a></li>
</ul>
</section>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2012/01/08/android%e3%81%a7%e3%82%ae%e3%83%a3%e3%83%a9%e3%83%aa%e3%83%bc%e3%81%a8%e9%80%a3%e6%90%ba%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>androidで顔検出する</title>
		<link>http://blog.justoneplanet.info/2011/12/29/android%e3%81%a7%e9%a1%94%e6%a4%9c%e5%87%ba%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2011/12/29/android%e3%81%a7%e9%a1%94%e6%a4%9c%e5%87%ba%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 14:19:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4887</guid>
		<description><![CDATA[int maxFaces = 10;// 検出する顔の最大数 FaceDetector detector = new FaceDetector(bitmap.getWidth(), bitmap.getHeight(), [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: java;">
int maxFaces = 10;// 検出する顔の最大数
FaceDetector detector = new FaceDetector(bitmap.getWidth(), bitmap.getHeight(), maxFaces);
FaceDetector.Face[] faces = new FaceDetector.Face[maxFaces];
ArrayList&lt;Bitmap&gt; recognized = new ArrayList&lt;Bitmap&gt;();

// bitmapの中から顔を検出してfacesに格納する
int num = detector.findFaces(bitmap, faces);

// facesに格納されたデータから座標情報を取り出してbitmapを切り出す
for (int i = 0; i &lt; num; i++) {
    FaceDetector.Face face = faces[i];
    PointF point = new PointF(0.0f, 0.0f);
    face.getMidPoint(point);

    int x = (int) (point.x - 1.5f * face.eyesDistance());
    int y = (int) (point.y - 2 * face.eyesDistance());
    int width  = (int) (face.eyesDistance() * 3);
    int height = (int) (face.eyesDistance() * 4);
    x = (x &lt; 0)? 0 : x;
    y = (y &lt; 0)? 0 : y;
    width = (width &gt; bitmap.getWidth())? bitmap.getWidth() : width;
    height = (height &gt; bitmap.getHeight())? bitmap.getHeight() : height;
    recognized.add(Bitmap.createBitmap(bitmap, x, y, width, height));
}
return recognized;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2011/12/29/android%e3%81%a7%e9%a1%94%e6%a4%9c%e5%87%ba%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>androidでprivateメソッドのテストをする</title>
		<link>http://blog.justoneplanet.info/2011/12/25/android%e3%81%a7private%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88%e3%82%92%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2011/12/25/android%e3%81%a7private%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88%e3%82%92%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Sat, 24 Dec 2011 16:53:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4882</guid>
		<description><![CDATA[そういえば書いてなかったのでメモ。 /** * Hogeクラスのprivateメソッドadd(int a, int b)をテストする * @throws SecurityException * @throws Illeg [...]]]></description>
			<content:encoded><![CDATA[<p>そういえば書いてなかったのでメモ。</p>
<pre class="brush: java;">
    /**
     * Hogeクラスのprivateメソッドadd(int a, int b)をテストする
     * @throws SecurityException
     * @throws IllegalArgumentException
     * @throws NoSuchMethodException
     * @throws IllegalAccessException
     * @throws InvocationTargetException
     */
    public void testAdd() throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
        Hoge hoge = new Hoge();
        Class&lt;Hoge&gt; clz = Hoge.class;
        Method method = clz.getDeclaredMethod(&quot;add&quot;, Integer.class, Integer.class);
        method.setAccessible(true);
        int result = (int) method.invoke(hoge, 5, 3);
        asserTrue(result == 8);
    }
</pre>
<p>staticメソッドの場合は以下のようになる。</p>
<pre class="brush: java;">
    /**
     * Hogeクラスのprivate staticメソッドadd(int a, int b)をテストする
     * @throws SecurityException
     * @throws IllegalArgumentException
     * @throws NoSuchMethodException
     * @throws IllegalAccessException
     * @throws InvocationTargetException
     */
    public void testAdd() throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
        Class&lt;Hoge&gt; clz = Hoge.class;
        Method method = clz.getDeclaredMethod(&quot;add&quot;, Integer.class, Integer.class);
        method.setAccessible(true);
        int result = (int) method.invoke(clz, 5, 3);
        asserTrue(result == 8);
    }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2011/12/25/android%e3%81%a7private%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88%e3%82%92%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>androidでArrayAdapterを使う</title>
		<link>http://blog.justoneplanet.info/2011/12/24/android%e3%81%a7arrayadapter%e3%82%92%e4%bd%bf%e3%81%86/</link>
		<comments>http://blog.justoneplanet.info/2011/12/24/android%e3%81%a7arrayadapter%e3%82%92%e4%bd%bf%e3%81%86/#comments</comments>
		<pubDate>Sat, 24 Dec 2011 11:05:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4876</guid>
		<description><![CDATA[■実装 mListView = (ListView) findViewById(R.id.list); mListView.setAdapter(mOriginalArrayAdapter); mOriginalArra [...]]]></description>
			<content:encoded><![CDATA[<h3>■実装</h3>
<pre class="brush: java;">
mListView = (ListView) findViewById(R.id.list);
mListView.setAdapter(mOriginalArrayAdapter);
</pre>
<p>mOriginalArrayAdapterを生成するとする。</p>
<pre class="brush: java;">
public class OriginalArrayAdapter extends ArrayAdapter&lt;OriginalDataRow&gt; {
    private LayoutInflater inflater;

    /**
     * セル内における可変要素
     */
    public static class ViewHolder {
        public TextView text;
    }

    public OriginalArrayAdapter(Context context, int textViewResourceId, ArrayList&lt;OriginalDataRow&gt; data) {
        super(context, textViewResourceId, data);
        inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final OriginalDataRow data = getItem(position);// フィールドなどから取得してはいけない...(a)

        // viewのセットアップ
        ViewHolder holder = null;
        if (convertView == null){
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.cell_original_data, null);
            holder.text = (TextView) convertView.findViewById(R.id.text);
            convertView.setTag(holder);
        }
        else {
            holder = (ViewHolder) convertView.getTag();
        }

        // dataをviewに書き出す
        holder.text.setText(data.text);
        return convertView;
    }
}
</pre>
<h4>filterを使用する</h4>
<pre class="brush: java;">
    @Override
    public void onTextChanged(CharSequence s, int start, int count, int after) {
        String query = mEditText.getText().toString();
        if (query.equals(&quot;&quot;)) {
            mListView.clearTextFilter();
        }
        else {
            mListView.setFilterText(query);
        }
    }
</pre>
<p>(a)の部分でsuperクラスのgetItemを使用しないとフィルタリングが上手く適用されない。また、filterを使用する場合は、リストアイテムのtoString値が使用されるため、以下のように必要に応じてOverrideする必要がある。</p>
<pre class="brush: java;">
public class OriginalDataRow {
    public String name;
    @Override
    public String toString() {
        return name;// filterに使用する文字列
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2011/12/24/android%e3%81%a7arrayadapter%e3%82%92%e4%bd%bf%e3%81%86/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP 2.0.4で多言語対応する</title>
		<link>http://blog.justoneplanet.info/2011/12/23/cakephp%e3%81%a7%e5%a4%9a%e8%a8%80%e8%aa%9e%e5%af%be%e5%bf%9c%e3%81%99%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2011/12/23/cakephp%e3%81%a7%e5%a4%9a%e8%a8%80%e8%aa%9e%e5%af%be%e5%bf%9c%e3%81%99%e3%82%8b/#comments</comments>
		<pubDate>Fri, 23 Dec 2011 14:27:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4871</guid>
		<description><![CDATA[■手順 アプリケーションのrootディレクトリで以下のコマンドを実行する。 php lib/Cake/Console/cake.php i18n 以下のように表示される。 Welcome to CakePHP v2.0. [...]]]></description>
			<content:encoded><![CDATA[<h3>■手順</h3>
<p>アプリケーションのrootディレクトリで以下のコマンドを実行する。</p>
<pre class="brush: bash;">
php lib/Cake/Console/cake.php i18n
</pre>
<p>以下のように表示される。</p>
<pre class="brush: bash;">
Welcome to CakePHP v2.0.4 Console
---------------------------------------------------------------
App : app
Path: /var/www/domain/app/
---------------------------------------------------------------
I18n Shell
---------------------------------------------------------------
[E]xtract POT file from sources
[I]nitialize i18n database table
[H]elp
[Q]uit
What would you like to do? (E/I/H/Q)
</pre>
<p>Eを選択する。</p>
<pre class="brush: bash;">
What is the path you would like to extract?
[Q]uit [D]one
[/var/www/domain/app/] &gt;
</pre>
<p>Dを選択する。</p>
<pre class="brush: bash;">
What is the path you would like to output?
[Q]uit
[/var/www/domain/app//Locale] &gt;
Would you like to merge all domains strings into the default.pot file? (y/n)
</pre>
<p>yを選択すると、ファイルを読み込んでデフォルトの言語ファイルが生成される。</p>
<ul>
<li>/var/www/domain/app/Locale/default.pot</li>
<li>/var/www/domain/app/Locale/eng</li>
</ul>
<p>/var/www/domain/app/Locale/engをコピーして/var/www/domain/app/Locale/jpnを作り、/var/www/domain/app/Locale/default.potをコピーして、/var/www/domain/app/Locale/jpn/LC_MESSAGES/default.poを作る。この時、拡張子を変更しないと上手く動作しない。</p>
<h4>翻訳ファイル</h4>
<p>翻訳ファイルは以下のように記述する。</p>
<pre class="brush: bash;">
#: Controller/HogeController.php:65;166;188;214
msgid &quot;Hello world&quot;
msgstr &quot;世界こんにちわ&quot;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2011/12/23/cakephp%e3%81%a7%e5%a4%9a%e8%a8%80%e8%aa%9e%e5%af%be%e5%bf%9c%e3%81%99%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP 2.0でログインフォームを作る</title>
		<link>http://blog.justoneplanet.info/2011/11/13/cakephp-2-0%e3%81%a7%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%83%95%e3%82%a9%e3%83%bc%e3%83%a0%e3%82%92%e4%bd%9c%e3%82%8b/</link>
		<comments>http://blog.justoneplanet.info/2011/11/13/cakephp-2-0%e3%81%a7%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%83%95%e3%82%a9%e3%83%bc%e3%83%a0%e3%82%92%e4%bd%9c%e3%82%8b/#comments</comments>
		<pubDate>Sun, 13 Nov 2011 08:46:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.justoneplanet.info/?p=4767</guid>
		<description><![CDATA[■実装 app/Controller/UsersController.php App::uses('AppController', 'Controller'); /** * Users Controller * @pro [...]]]></description>
			<content:encoded><![CDATA[<h3>■実装</h3>
<h4>app/Controller/UsersController.php</h4>
<pre class="brush: php;">
App::uses('AppController', 'Controller');
/**
 * Users Controller
 * @property User $User
 */
class UsersController extends AppController {

    public $uses = array('User');

    public $components = array(
        'Session',
        'Auth' =&gt; array(
            'loginRedirect' =&gt; array('controller'  =&gt; 'users', 'action' =&gt; 'index'),// ログイン後のリダイレクト先
            'logoutRedirect' =&gt; array('controller' =&gt; 'pages', 'action' =&gt; 'display', 'home')// ログアウト後のリダイレクト先
        )
    );

    public function beforeFilter() {
        //$this-&gt;Auth-&gt;allow('index'/*, 'add'*/);// 認証を除外するアクションを指定する
    }

    /**
     * ユーザを追加する画面
     * @return void
     */
    public function add() {
        /*if ($this-&gt;request-&gt;is('post')) {
            $this-&gt;User-&gt;create();
            if ($this-&gt;User-&gt;save($this-&gt;request-&gt;data)) {
                $this-&gt;Session-&gt;setFlash(__('The user has been saved'));
                $this-&gt;redirect(array('action' =&gt; 'index'));
            }
            else {
                $this-&gt;Session-&gt;setFlash(__('The user could not be saved. Please, try again.'));
            }
        }*/
    }

    /**
     * ログイン画面
     * @return void
     */
    public function admin_login() {
        if ($this-&gt;Auth-&gt;login()) {
            $this-&gt;redirect($this-&gt;Auth-&gt;redirect());
        }
        else {
            $this-&gt;Session-&gt;setFlash(__('Invalid username or password, try again'));
        }
    }

    /**
     * ログアウト画面
     * @return void
     */
    public function admin_logout() {
        $this-&gt;redirect($this-&gt;Auth-&gt;logout());
    }
}
</pre>
<h4>app/Model/User.php</h4>
<pre class="brush: php;">
App::uses('AppModel', 'Model');

/**
 * User Model
 * ユーザのモデル
 */
class User extends AppModel {
    public function __construct($id = false, $table = null, $ds = null) {
        $this-&gt;useDbConfig = Configure::read('Config.environment');
        parent::__construct($id, $table, $ds);
    }

    /**
     * 保存前に実行される
     * @return void
     */
    public function beforeSave() {
        if (isset($this-&gt;data[$this-&gt;alias]['password'])) {
            $this-&gt;data[$this-&gt;alias]['password'] = AuthComponent::password($this-&gt;data[$this-&gt;alias]['password']);
        }
        return true;
    }

}
</pre>
<p>Cake1系ではpasswordというカラム名が自動的にハッシュ化されていた。Cake2系では上述のように実装する必要がある。</p>
<h4>app/View/Users/admin_login.ctp</h4>
<p>以下のようにログインフォームを記述する。</p>
<pre class="brush: php;">
&lt;?php echo $this-&gt;Session-&gt;flash('auth'); ?&gt;
&lt;?php echo $this-&gt;Form-&gt;create('User');?&gt;
&lt;fieldset&gt;
&lt;legend&gt;&lt;?php echo __('Please enter your username and password'); ?&gt;&lt;/legend&gt;
&lt;?php
echo $this-&gt;Form-&gt;input('username');
echo $this-&gt;Form-&gt;input('password');
?&gt;
&lt;/fieldset&gt;
&lt;?php echo $this-&gt;Form-&gt;end(__('Login'));?&gt;
</pre>
<p>$thisを介してSessionとFormにアクセスするところがCake2系では異なる。</p>
<h4>app/View/Users/admin_logout.ctp</h4>
<pre class="brush: php;">
&lt;h3&gt;ログアウトしました。&lt;/h3&gt;
</pre>
<h3>■参考</h3>
<ul>
<li><a href="http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html">Simple Authentication and Authorization Application</a></li>
<li><a href="http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html">Authentication</a></li>
</ul>
<p>殆ど参考文献の簡略化日本語版だな。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.justoneplanet.info/2011/11/13/cakephp-2-0%e3%81%a7%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%83%95%e3%82%a9%e3%83%bc%e3%83%a0%e3%82%92%e4%bd%9c%e3%82%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

