<?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>Code Library &#187; General</title>
	<atom:link href="http://www.ucosoft.com/category/uncategorized/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ucosoft.com</link>
	<description>Free Source Code and Program Tips</description>
	<lastBuildDate>Thu, 22 Jul 2010 05:17:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Eclipse developed Android, Hello, TimePicker (study 8)</title>
		<link>http://www.ucosoft.com/eclipse-developed-android-timepicker-study-2.html</link>
		<comments>http://www.ucosoft.com/eclipse-developed-android-timepicker-study-2.html#comments</comments>
		<pubDate>Fri, 18 Dec 2009 16:50:28 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[developed]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[timepicker]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/uncategorized/eclipse-developed-android-timepicker-study-2.html</guid>
		<description><![CDATA[Hello, TimePicker A TimePicker is a Widget that allows the User to Select the time by hour, minute and AM or PM. &#160; &#160; Start a new project / Activity called HelloTimePicker. &#160; Modify HelloTimePicker.java code is as follows: &#160; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [...]]]></description>
			<content:encoded><![CDATA[<h1>Hello, TimePicker</h1>
<div>
<div class="jd-descr">
<p>A <code>TimePicker</code> is a Widget that allows the User to Select the time by hour, minute and AM or PM.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Start a new project / Activity <strong>called</strong> HelloTimePicker.</p>
<p>&nbsp;</p>
<p>Modify HelloTimePicker.java code is as follows:</p>
<p>&nbsp;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.example.test</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Calendar</span><span style="color: #339933;">;</span>
<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.app.Dialog</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.app.TimePickerDialog</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>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.View</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.Button</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.TextView</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.TimePicker</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HelloTimePicker <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">private</span> TextView mTimeDisplay<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Button</span> mPickTime<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> mHour<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> mMinute<span style="color: #339933;">;</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> TIME_DIALOG_ID <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
@ Overrideprotected <span style="color: #000066; font-weight: bold;">void</span> onCreate <span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span> <span style="color: #009900;">&#40;</span>savedInstanceState<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: #339933;">/</span> <span style="color: #339933;">/</span> capture our <span style="color: #003399;">View</span> elements mTimeDisplay <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>TextView<span style="color: #009900;">&#41;</span> findViewById <span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">timeDisplay</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
mPickTime <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Button</span><span style="color: #009900;">&#41;</span> findViewById <span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">pickTime</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">/</span> <span style="color: #339933;">/</span> add a click listener to the button mPickTime.<span style="color: #006633;">setOnClickListener</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">View</span>.<span style="color: #006633;">OnClickListener</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onClick <span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> v<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>showDialog <span style="color: #009900;">&#40;</span>TIME_DIALOG_ID<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">/</span> <span style="color: #339933;">/</span> get the current time <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Calendar</span> c <span style="color: #339933;">=</span> <span style="color: #003399;">Calendar</span>.<span style="color: #006633;">getInstance</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
mHour <span style="color: #339933;">=</span> c.<span style="color: #006633;">get</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Calendar</span>.<span style="color: #006633;">HOUR_OF_DAY</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
mMinute <span style="color: #339933;">=</span> c.<span style="color: #006633;">get</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Calendar</span>.<span style="color: #006633;">MINUTE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">/</span> <span style="color: #339933;">/</span> display the current date updateDisplay <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
Overrideprotected <span style="color: #003399;">Dialog</span> onCreateDialog <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">case</span> TIME_DIALOG_ID<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> TimePickerDialog <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, mTimeSetListener, mHour, mMinute, <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #339933;">/</span> updates the time we display in the TextViewprivate <span style="color: #000066; font-weight: bold;">void</span> updateDisplay <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>mTimeDisplay.<span style="color: #006633;">setText</span> <span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> StringBuilder <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">append</span> <span style="color: #009900;">&#40;</span>pad <span style="color: #009900;">&#40;</span>mHour<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">append</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;:&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">append</span> <span style="color: #009900;">&#40;</span>pad <span style="color: #009900;">&#40;</span>mMinute <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">private</span> TimePickerDialog.<span style="color: #006633;">OnTimeSetListener</span> mTimeSetListener <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TimePickerDialog.<span style="color: #006633;">OnTimeSetListener</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onTimeSet <span style="color: #009900;">&#40;</span>TimePicker view, <span style="color: #000066; font-weight: bold;">int</span> hourOfDay, <span style="color: #000066; font-weight: bold;">int</span> minute<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>mHour <span style="color: #339933;">=</span> hourOfDay<span style="color: #339933;">;</span>
mMinute <span style="color: #339933;">=</span> minute<span style="color: #339933;">;</span>
updateDisplay <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> pad <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>
<span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #003399;">String</span>.<span style="color: #006633;">valueOf</span> <span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;+</span> <span style="color: #003399;">String</span>.<span style="color: #006633;">valueOf</span> <span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>Layout-&gt; main.xml</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;?</span> xml version <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #cc66cc;">1.0</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> encoding <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>utf<span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;?&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>LinearLayout xmlns<span style="color: #339933;">:</span> android <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//schemas.android.com/apk/res/android&amp;quot; android: layout_width = &amp;quot;wrap_content&amp;quot; android: layout_height = &amp;quot;wrap_content&amp;quot; android: orientation = &amp;quot;vertical&amp;quot;&amp;gt; &amp;lt;TextView android:id=&amp;quot;@+id/timeDisplay&amp;quot; android:layout_width=&amp;quot;wrap_content&amp;quot; android:layout_height=&amp;quot;wrap_content&amp;quot; android:text=&amp;quot;&amp;quot;/&amp;gt; &amp;lt;Button android : id = &amp;quot;@ + id / pickTime&amp;quot; android: layout_width = &amp;quot;wrap_content&amp;quot; android: layout_height = &amp;quot;wrap_content&amp;quot; android: text = &amp;quot;Change the time &amp;quot;/&amp;gt;&amp;lt;/ LinearLayout&amp;gt;</span></pre></td></tr></table></div>

<p>&nbsp;</p>
<p>Run Now run it. Run the results are as follows:</p>
<p><img height="284" width="200" alt="" src="/images/345eb4ffa77115deb9d4fb0bef7c3ac2.png" /></p>
<p>&nbsp;</p>
<p>Source Download: HelloTimePicker.zip</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
</div>

	Tags: <strong><a href="http://www.ucosoft.com/tag/android" title="android" rel="tag">android</a>, <a href="http://www.ucosoft.com/tag/developed" title="developed" rel="tag">developed</a>, <a href="http://www.ucosoft.com/tag/eclipse" title="eclipse" rel="tag">eclipse</a>, <a href="http://www.ucosoft.com/tag/study" title="study" rel="tag">study</a>, <a href="http://www.ucosoft.com/tag/timepicker" title="timepicker" rel="tag">timepicker</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/eclipse-developed-android-timepicker-study-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse developed Android, Hello, WebView (study 6)</title>
		<link>http://www.ucosoft.com/eclipse-developed-android-webview-study-2.html</link>
		<comments>http://www.ucosoft.com/eclipse-developed-android-webview-study-2.html#comments</comments>
		<pubDate>Fri, 18 Dec 2009 14:21:54 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[developed]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[webview]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/uncategorized/eclipse-developed-android-webview-study-2.html</guid>
		<description><![CDATA[Hello, WebView A WebView allows you to Create your own Web Browser Activity. In this Tutorial, we&#39;ll Create a simple Activity that can View Web pages. Learning Address: http://androidappdocs.appspot.com/guide/tutorials/views/hello-webview.html HelloWebView.java Code 1 package com.example.test; import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; public class HelloWebView extends Activity &#40;WebView webview; / ** Called when the activity is first [...]]]></description>
			<content:encoded><![CDATA[<h1>  Hello, WebView </h1>
<div>
<div class=jd-descr>
<p> A <code>WebView</code> allows you to Create your own Web Browser Activity. In this Tutorial, we&#39;ll Create a simple Activity that can View Web pages. </p>
</p>
<p>  Learning Address: http://androidappdocs.appspot.com/guide/tutorials/views/hello-webview.html </p>
</p>
<p>  HelloWebView.java Code </p>
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.example.test</span><span style="color: #339933;">;</span> <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> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.webkit.WebView</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HelloWebView <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#40;</span>WebView webview<span style="color: #339933;">;</span> <span style="color: #339933;">/</span> <span style="color: #339933;">**</span> Called when the activity is first created. <span style="color: #339933;">*</span> <span style="color: #339933;">/</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 savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span> <span style="color: #009900;">&#40;</span>savedInstanceState<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> webview <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>WebView<span style="color: #009900;">&#41;</span> findViewById <span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">webview</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> webview.<span style="color: #006633;">getSettings</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">setJavaScriptEnabled</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span> webview.<span style="color: #006633;">loadUrl</span> <span style="color: #009900;">&#40;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//ditu.google.cn);))</span></pre></td></tr></table></div>

</p>
<p>  Layout-&gt; main.xml </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;?</span> xml version <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #cc66cc;">1.0</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> encoding <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>utf<span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;?&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>LinearLayout xmlns<span style="color: #339933;">:</span> android <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//schemas.android.com/apk/res/android&amp;quot; android: layout_width = &amp;quot;wrap_content&amp;quot; android: layout_height = &amp;quot;wrap_content&amp;quot; android: orientation = &amp;quot;vertical&amp;quot;&amp;gt; &amp;lt;WebView android:id=&amp;quot;@+id/webview&amp;quot; android:layout_width=&amp;quot;fill_parent&amp;quot; android:layout_height=&amp;quot;fill_parent&amp;quot; /&amp;gt; &amp;lt;/ LinearLayout&amp;gt;</span></pre></td></tr></table></div>

</p>
<p>  Implementation of the Eclipse-&gt; HelloWebViewAndroid-&gt; Android Application Show pictures are as follows: </p>
</p>
<p><img src=/images/5ab84791881f6453736271357496b644.png alt="" width=341 height=501 /></p>
</p>
<p>  Code download HelloWebView.zip </p>
</p>
</div>
</div>

	Tags: <strong><a href="http://www.ucosoft.com/tag/android" title="android" rel="tag">android</a>, <a href="http://www.ucosoft.com/tag/developed" title="developed" rel="tag">developed</a>, <a href="http://www.ucosoft.com/tag/eclipse" title="eclipse" rel="tag">eclipse</a>, <a href="http://www.ucosoft.com/tag/study" title="study" rel="tag">study</a>, <a href="http://www.ucosoft.com/tag/webview" title="webview" rel="tag">webview</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/eclipse-developed-android-webview-study-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse developed Android, RelativeLayout (study 3)</title>
		<link>http://www.ucosoft.com/eclipse-developed-android-relativelayout-study-2.html</link>
		<comments>http://www.ucosoft.com/eclipse-developed-android-relativelayout-study-2.html#comments</comments>
		<pubDate>Fri, 18 Dec 2009 10:15:06 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[developed]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[relativelayout]]></category>
		<category><![CDATA[study]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/uncategorized/eclipse-developed-android-relativelayout-study-2.html</guid>
		<description><![CDATA[Hello, RelativeLayout A RelativeLayout is a ViewGroup that allows you to layout child elements in positions relative to the parent or siblings elements. Start a new project / Activity called HelloRelativeLayout. Open the layout file. Make it like so: 1 &#38;lt;? xml version = &#38;quot;1.0&#38;quot; encoding = &#38;quot;utf-8&#38;quot;?&#38;gt; &#38;lt;RelativeLayout xmlns: android = &#38;quot;http://schemas.android.com/apk/res/android&#38;quot; android: layout_width [...]]]></description>
			<content:encoded><![CDATA[<h1>  Hello, RelativeLayout </h1>
<div>
<p class=jd-descr> A <code>RelativeLayout</code> is a ViewGroup that allows you to layout child elements in positions relative to the parent or siblings elements. </p>
<div class=jd-descr>
<ol>
<li>  Start a new project / Activity called HelloRelativeLayout. </li>
<li>  Open the layout file. Make it like so:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;?</span> xml version <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #cc66cc;">1.0</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> encoding <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>utf<span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;?&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>RelativeLayout xmlns<span style="color: #339933;">:</span> android <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//schemas.android.com/apk/res/android&amp;quot; android: layout_width = &amp;quot;fill_parent&amp;quot; android: layout_height = &amp;quot;fill_parent&amp;quot;&amp;gt; &amp;lt;TextView android:id=&amp;quot;@+id/label&amp;quot; android:layout_width=&amp;quot;fill_parent&amp;quot; android:layout_height=&amp;quot;wrap_content&amp;quot; android:text=&amp;quot;Type here:&amp;quot;/&amp;gt; &amp;lt;EditText android: id = &amp;quot; @ + id / entry &amp;quot;android: layout_width =&amp;quot; fill_parent &amp;quot;android: layout_height =&amp;quot; wrap_content &amp;quot;android: background =&amp;quot; @ android: drawable / editbox_background &amp;quot;android: layout_below =&amp;quot; @ id / label &amp;quot;/&amp;gt; &amp;lt;Button android: id = &amp;quot;@ + id / ok&amp;quot; android: layout_width = &amp;quot;wrap_content&amp;quot; android: layout_height = &amp;quot;wrap_content&amp;quot; android: layout_below = &amp;quot;@ id / entry&amp;quot; android: layout_alignParentRight = &amp;quot;true&amp;quot; android: layout_marginLeft = &amp;quot;10dip&amp;quot; android: text = &amp;quot; OK &amp;quot;/&amp;gt; &amp;lt;Button android:layout_width=&amp;quot;wrap_content&amp;quot; android:layout_height=&amp;quot;wrap_content&amp;quot; android:layout_toLeftOf=&amp;quot;@id/ok&amp;quot; android:layout_alignTop=&amp;quot;@id/ok&amp;quot; android:text=&amp;quot;Cancel&amp;quot; /&amp;gt; &amp;lt; / RelativeLayout&amp;gt;</span></pre></td></tr></table></div>

<p>  Pay attention to each of the additional <code>layout_*</code> attributes (besides the usual width and height, which are required for all elements). When using relative layout, we use attributes like <code>layout_below</code> and <code>layout_toLeftOf</code> to describe How we&#39;d like to position each View. Naturally, these are different relative positions, and the value of the attribute is the id of the element we want the position relative to. </p>
</li>
<li>  Make sure your Activity loads this layout in the <code>onCreate()</code> method:
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <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 savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span> <span style="color: #009900;">&#40;</span>savedInstanceState<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;">&#41;</span></pre></td></tr></table></div>

<p>  <code>R.layout.main</code> refers to the <code>main.xml</code> layout file. </p>
</li>
<li>  Run it. </li>
</ol>
</div>
</div>

	Tags: <strong><a href="http://www.ucosoft.com/tag/android" title="android" rel="tag">android</a>, <a href="http://www.ucosoft.com/tag/developed" title="developed" rel="tag">developed</a>, <a href="http://www.ucosoft.com/tag/eclipse" title="eclipse" rel="tag">eclipse</a>, <a href="http://www.ucosoft.com/tag/relativelayout" title="relativelayout" rel="tag">relativelayout</a>, <a href="http://www.ucosoft.com/tag/study" title="study" rel="tag">study</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/eclipse-developed-android-relativelayout-study-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse developed Android, Hello Spinner (Study 10)</title>
		<link>http://www.ucosoft.com/eclipse-developed-android-spinner-study-2.html</link>
		<comments>http://www.ucosoft.com/eclipse-developed-android-spinner-study-2.html#comments</comments>
		<pubDate>Fri, 18 Dec 2009 07:51:34 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[developed]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[spinner]]></category>
		<category><![CDATA[study]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/uncategorized/eclipse-developed-android-spinner-study-2.html</guid>
		<description><![CDATA[HelloSpinner.java Source 1 package com.example.test; import android.app.Activity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.Spinner; public class HelloSpinner extends Activity &#40;@ Overridepublic void onCreate &#40;Bundle savedInstanceState&#41; &#40; super.onCreate &#40;savedInstanceState&#41;; setContentView &#40;R.layout.main&#41;; Spinner s = &#40;Spinner&#41; findViewById &#40;R.id.spinner&#41;; ArrayAdapter adapter = ArrayAdapter.createFromResource &#40;this, R.array.planets, android.R. layout.simple_spinner_item&#41;; adapter.setDropDownViewResource &#40;android.R.layout.simple_spinner_dropdown_item&#41;; s.setAdapter &#40;adapter&#41;;&#41;&#41; layout-&#62; main.xml 1 &#38;lt;? xml version = &#38;quot;1.0&#38;quot; [...]]]></description>
			<content:encoded><![CDATA[<p>  HelloSpinner.java Source </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.example.test</span><span style="color: #339933;">;</span> <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> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.ArrayAdapter</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.Spinner</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HelloSpinner <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#40;</span>@ Overridepublic <span style="color: #000066; font-weight: bold;">void</span> onCreate <span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span> <span style="color: #009900;">&#40;</span>savedInstanceState<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> Spinner s <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Spinner<span style="color: #009900;">&#41;</span> findViewById <span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">spinner</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> ArrayAdapter adapter <span style="color: #339933;">=</span> ArrayAdapter.<span style="color: #006633;">createFromResource</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>, R.<span style="color: #006633;">array</span>.<span style="color: #006633;">planets</span>, android.<span style="color: #006633;">R</span>. <span style="color: #006633;">layout</span>.<span style="color: #006633;">simple_spinner_item</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> adapter.<span style="color: #006633;">setDropDownViewResource</span> <span style="color: #009900;">&#40;</span>android.<span style="color: #006633;">R</span>.<span style="color: #006633;">layout</span>.<span style="color: #006633;">simple_spinner_dropdown_item</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> s.<span style="color: #006633;">setAdapter</span> <span style="color: #009900;">&#40;</span>adapter<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>  layout-&gt; main.xml </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;?</span> xml version <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #cc66cc;">1.0</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> encoding <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>utf<span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;?&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>LinearLayout xmlns<span style="color: #339933;">:</span> android <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//schemas.android.com/apk/res/android&amp;quot; android: orientation = &amp;quot;vertical&amp;quot; android: padding = &amp;quot;10dip&amp;quot; android: layout_width = &amp;quot;fill_parent&amp;quot; android: layout_height = &amp;quot;wrap_content&amp;quot;&amp;gt; &amp;lt;TextView android: layout_width = &amp;quot;fill_parent&amp;quot; android: layout_height = &amp;quot;wrap_content&amp;quot; android: layout_marginTop = &amp;quot;10dip&amp;quot; android: text = &amp;quot;Please select a planet: &amp;quot;/&amp;gt; &amp;lt;Spinner android: id =&amp;quot; @ + id / spinner &amp;quot;android: layout_width =&amp;quot; fill_parent &amp;quot;android: layout_height =&amp;quot; wrap_content &amp;quot;android: drawSelectorOnTop =&amp;quot; true &amp;quot;android: prompt =&amp;quot; @ string / planet_prompt &amp;quot;/ &amp;gt; &amp;lt;/ LinearLayout&amp;gt;</span></pre></td></tr></table></div>

<p>  values-&gt; arrays.xml </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>resources<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>string<span style="color: #339933;">-</span>array name<span style="color: #339933;">=&amp;</span>quot<span style="color: #339933;">;</span>planets<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>item<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> Mercury <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;/</span> item<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>item<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> Venus <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;/</span> item<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>item<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> Earth <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;/</span> item<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>item<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> Mars <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;/</span> item<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>item<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> Jupiter <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #339933;">/</span> item<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>item<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> Saturn <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;/</span> item<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>item<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> Uranus <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;/</span> item<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>item<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> Neptune <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;/</span> item<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;/</span> string<span style="color: #339933;">-</span>array<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;/</span> resources<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>  value-&gt; strings.xml </p>
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;?</span> xml version <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #cc66cc;">1.0</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> encoding <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>utf<span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;?&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>resources<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>string name<span style="color: #339933;">=&amp;</span>quot<span style="color: #339933;">;</span>hello<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;&amp;</span>gt<span style="color: #339933;">;</span> Hello World, HelloSpinner<span style="color: #339933;">!</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;/</span> string<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>string name<span style="color: #339933;">=&amp;</span>quot<span style="color: #339933;">;</span>app_name<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;&amp;</span>gt<span style="color: #339933;">;</span> HelloSpinner <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;/</span> string<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>string name<span style="color: #339933;">=&amp;</span>quot<span style="color: #339933;">;</span>planet_prompt<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;&amp;</span>gt<span style="color: #339933;">;</span> Choose a planet <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;/</span> string<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;/</span> resources<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></pre></td></tr></table></div>

</p>
<p>  run it <img src=/images/2a6d1cb47d7db3e832cd4b13bd065d1c.png alt="" /></p></p>

	Tags: <strong><a href="http://www.ucosoft.com/tag/android" title="android" rel="tag">android</a>, <a href="http://www.ucosoft.com/tag/developed" title="developed" rel="tag">developed</a>, <a href="http://www.ucosoft.com/tag/eclipse" title="eclipse" rel="tag">eclipse</a>, <a href="http://www.ucosoft.com/tag/spinner" title="spinner" rel="tag">spinner</a>, <a href="http://www.ucosoft.com/tag/study" title="study" rel="tag">study</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/eclipse-developed-android-spinner-study-2.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Android View Add Listener Tips Sample</title>
		<link>http://www.ucosoft.com/add-listener-tips-android-view-2.html</link>
		<comments>http://www.ucosoft.com/add-listener-tips-android-view-2.html#comments</comments>
		<pubDate>Fri, 18 Dec 2009 03:29:40 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[add]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[listener]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/uncategorized/add-listener-tips-android-view-2.html</guid>
		<description><![CDATA[In the development for the control to add Listener is a very common work, the easiest way to add Listener can be: 1 findViewById &#40;R.id.myButton&#41;. setOnClickListener &#40;new View.OnClickListener &#40;&#41; &#40;public void onClick &#40;View v&#41; &#40;/ / Do stuff&#41;&#41;&#41;; Add a Listener using the above method has a drawback is that if control is too large, [...]]]></description>
			<content:encoded><![CDATA[<p>  In the development for the control to add Listener is a very common work, the easiest way to add Listener can be: </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  findViewById <span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">myButton</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">setOnClickListener</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">View</span>.<span style="color: #006633;">OnClickListener</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onClick <span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> v<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span> <span style="color: #339933;">/</span> <span style="color: #000000; font-weight: bold;">Do</span> stuff<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>  Add a Listener using the above method has a drawback is that if control is too large, Listener will increase the number, so the following tips can be used to reduce the number of Listener: </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #003399;">View</span>.<span style="color: #006633;">OnClickListener</span> handler <span style="color: #339933;">=</span> <span style="color: #003399;">View</span>.<span style="color: #006633;">OnClickListener</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onClick <span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> v<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>v.<span style="color: #006633;">getId</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">case</span> R.<span style="color: #006633;">id</span>.<span style="color: #006633;">Button01</span><span style="color: #339933;">:</span> <span style="color: #339933;">/</span> <span style="color: #339933;">/</span> doStuff <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">case</span> R.<span style="color: #006633;">id</span>.<span style="color: #006633;">Button02</span><span style="color: #339933;">:</span> <span style="color: #339933;">/</span> <span style="color: #339933;">/</span> doStuff <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> findViewById <span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">myButton</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">setOnClickListener</span> <span style="color: #009900;">&#40;</span>handler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> findViewById <span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">myOtherButton</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">setOnClickListener</span> <span style="color: #009900;">&#40;</span>handler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>  The Android1.6 inside, add the Listener&#39;s work has become fairly simple (feeling more like doing web programming!), Concrete steps are as follows: </p>
<p>  1. First, the definition in the layout inside the Button and specify the response Listener </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;?</span> xml version <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #cc66cc;">1.0</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> encoding <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>utf<span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;?&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>LinearLayout xmlns<span style="color: #339933;">:</span> android <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//schemas.android.com/apk/res/android&amp;quot; android: orientation = &amp;quot;vertical&amp;quot; android: layout_width = &amp;quot;fill_parent&amp;quot; android: layout_height = &amp;quot;fill_parent&amp;quot;&amp;gt; &amp;lt;TextView android:layout_width=&amp;quot;fill_parent&amp;quot; android:layout_height=&amp;quot;wrap_content&amp;quot; android:text=&amp;quot;@string/hello&amp;quot; /&amp;gt; &amp;lt;Button android: text = &amp;quot;Button01&amp;quot; android : id = &amp;quot;@ + id/Button01&amp;quot; android: layout_width = &amp;quot;wrap_content&amp;quot; android: layout_height = &amp;quot;wrap_content&amp;quot; android: onClick = &amp;quot;myClickHandler01&amp;quot; /&amp;gt; &amp;lt;Button android: text = &amp;quot;Button02&amp;quot; android: id = &amp;quot;@ + id / Button02 &amp;quot;android: layout_width =&amp;quot; wrap_content &amp;quot;android: layout_height =&amp;quot; wrap_content &amp;quot;android: onClick =&amp;quot; myClickHandler02 &amp;quot;/&amp;gt; &amp;lt;TextView android: layout_width =&amp;quot; fill_parent &amp;quot;android: layout_height =&amp;quot; wrap_content &amp;quot;android: text =&amp;quot; @ string / hello &amp;quot;/&amp;gt; &amp;lt;/ LinearLayout&amp;gt;</span></pre></td></tr></table></div>

<p>  These two lines of which the following are new features: </p>
<p>  android: onClick = &quot;myClickHandler01&quot; </p>
<p>  android: onClick = &quot;myClickHandler02&quot; </p>
</p>
<p>  2. In the event inside the definition of public methods myClickHandler01, and myClickHandler02 (Note that these two methods must have a View of the shape parameter). </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.ray.test</span><span style="color: #339933;">;</span> <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> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.View</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TestOnClickListener <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#40;</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 savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span> <span style="color: #009900;">&#40;</span>savedInstanceState<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;">&#41;</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> myClickHandler01 <span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> target<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>setTitle <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>myClickHandler01<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> myClickHandler02 <span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> target<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>setTitle <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>myClickHandler02<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>  Of course, you can also use this wording: </p>
<p>  The two buttons set to the same Listener </p>
<p>  android: onClick = &quot;myClickHandler&quot; </p>
<p>  android: onClick = &quot;myClickHandler&quot; </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.ray.test</span><span style="color: #339933;">;</span> <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> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.View</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TestOnClickListener <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#40;</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 savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span> <span style="color: #009900;">&#40;</span>savedInstanceState<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;">&#41;</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> myClickHandler <span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> target<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>target.<span style="color: #006633;">getId</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">case</span> R.<span style="color: #006633;">id</span>.<span style="color: #006633;">Button01</span><span style="color: #339933;">:</span> setTitle <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>myClickHandler01<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">case</span> R.<span style="color: #006633;">id</span>.<span style="color: #006633;">Button02</span> <span style="color: #339933;">:</span> setTitle <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>myClickHandler02<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>  Refer to the article: &quot;UI framework changes in Android 1.6&quot; (take over the wall) </p>

	Tags: <strong><a href="http://www.ucosoft.com/tag/add" title="add" rel="tag">add</a>, <a href="http://www.ucosoft.com/tag/android" title="android" rel="tag">android</a>, <a href="http://www.ucosoft.com/tag/listener" title="listener" rel="tag">listener</a>, <a href="http://www.ucosoft.com/tag/tips" title="Tips" rel="tag">Tips</a>, <a href="http://www.ucosoft.com/tag/view" title="view" rel="tag">view</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/add-listener-tips-android-view-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse developed Android, Hello, MapView (study 5)</title>
		<link>http://www.ucosoft.com/eclipse-developed-android-mapview-study-2.html</link>
		<comments>http://www.ucosoft.com/eclipse-developed-android-mapview-study-2.html#comments</comments>
		<pubDate>Fri, 18 Dec 2009 01:01:06 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[developed]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[mapview]]></category>
		<category><![CDATA[study]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/uncategorized/eclipse-developed-android-mapview-study-2.html</guid>
		<description><![CDATA[Hello, MapView Learning Address: http://androidappdocs.appspot.com/guide/tutorials/views/hello-mapview.html HelloItemizedOverlay.java Code 1 package com.example.test; import java.util.ArrayList; import android.graphics.drawable.Drawable; import com.google.android.maps.ItemizedOverlay; import com.google.android.maps.OverlayItem; public class HelloItemizedOverlay extends ItemizedOverlay &#40;private ArrayList &#38;lt;OverlayItem&#38;gt; mOverlays = new ArrayList &#38;lt;OverlayItem&#38;gt; &#40;&#41;; public HelloItemizedOverlay &#40;Drawable defaultMarker&#41; &#40;super &#40;boundCenterBottom &#40;defaultMarker &#41;&#41;;// TODO Auto-generated constructor stub) @ Overridepublic int size () (return mOverlays. size ();) public void [...]]]></description>
			<content:encoded><![CDATA[<h1>  Hello, MapView </h1>
<p>  Learning Address: http://androidappdocs.appspot.com/guide/tutorials/views/hello-mapview.html </p>
</p>
<p>  HelloItemizedOverlay.java Code </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.example.test</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.graphics.drawable.Drawable</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.android.maps.ItemizedOverlay</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.android.maps.OverlayItem</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HelloItemizedOverlay <span style="color: #000000; font-weight: bold;">extends</span> ItemizedOverlay <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">ArrayList</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>OverlayItem<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> mOverlays <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ArrayList</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>OverlayItem<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">public</span> HelloItemizedOverlay <span style="color: #009900;">&#40;</span>Drawable defaultMarker<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span> <span style="color: #009900;">&#40;</span>boundCenterBottom <span style="color: #009900;">&#40;</span>defaultMarker <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// TODO Auto-generated constructor stub) @ Overridepublic int size () (return mOverlays. size ();) public void addOverlay (OverlayItem overlay) (mOverlays.add (overlay); populate ();}Overrideprotected OverlayItem createItem (int i) (return mOverlays.get (i);))</span></pre></td></tr></table></div>

</p>
<p>  HelloMapView1.java Code </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.example.test</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.graphics.drawable.Drawable</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> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.LinearLayout</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.ZoomControls</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.android</span> . <span style="color: #006633;">maps</span>.<span style="color: #006633;">GeoPoint</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.android.maps.MapActivity</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.android.maps.MapView</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.android.maps.Overlay</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.android.maps.OverlayItem</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HelloMapView1 <span style="color: #000000; font-weight: bold;">extends</span> MapActivity <span style="color: #009900;">&#40;</span>LinearLayout linearLayout<span style="color: #339933;">;</span> MapView mapView<span style="color: #339933;">;</span> ZoomControls mZoom<span style="color: #339933;">;</span> <span style="color: #003399;">List</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>Overlay<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> mapOverlays<span style="color: #339933;">;</span> Drawable drawable<span style="color: #339933;">;</span> HelloItemizedOverlay itemizedOverlay<span style="color: #339933;">;</span> <span style="color: #339933;">/</span> <span style="color: #339933;">**</span> Called when the activity is first created. <span style="color: #339933;">*</span> <span style="color: #339933;">/</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 savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span> . <span style="color: #006633;">onCreate</span> <span style="color: #009900;">&#40;</span>savedInstanceState<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> mapView <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>MapView<span style="color: #009900;">&#41;</span> findViewById <span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">mapview</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> mapView.<span style="color: #006633;">setBuiltInZoomControls</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> mapOverlays <span style="color: #339933;">=</span> mapView.<span style="color: #006633;">getOverlays</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> drawable <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getResources</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span>. <span style="color: #006633;">getDrawable</span> <span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">drawable</span>.<span style="color: #006633;">androidmarker</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> itemizedOverlay <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HelloItemizedOverlay <span style="color: #009900;">&#40;</span>drawable<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> GeoPoint point <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GeoPoint <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">19240000</span>, <span style="color: #339933;">-</span><span style="color: #cc66cc;">99120000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> OverlayItem overlayitem <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> OverlayItem <span style="color: #009900;">&#40;</span>point, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;&amp;</span>quot<span style="color: #339933;">;</span>, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> itemizedOverlay.<span style="color: #006633;">addOverlay</span> <span style="color: #009900;">&#40;</span> overlayitem<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> mapOverlays.<span style="color: #006633;">add</span> <span style="color: #009900;">&#40;</span>itemizedOverlay<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> @ Override <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">boolean</span> isRouteDisplayed <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>  Layout-&gt; mail.xml </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;?</span> xml version <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #cc66cc;">1.0</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> encoding <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>utf<span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;?&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>RelativeLayout xmlns<span style="color: #339933;">:</span> android <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//schemas.android.com/apk/res/android&amp;quot; android: id = &amp;quot;@ + id / mainlayout &amp;quot;android: orientation =&amp;quot; vertical &amp;quot;android: layout_width =&amp;quot; fill_parent &amp;quot;android: layout_height =&amp;quot; fill_parent &amp;quot;&amp;gt; &amp;lt;com.google.android.maps.MapView android: id =&amp;quot; @ + id / mapview &amp;quot;android: layout_width =&amp;quot; fill_parent &amp;quot;android: layout_height =&amp;quot; fill_parent &amp;quot;android: clickable =&amp;quot; true &amp;quot;android: apiKey =&amp;quot; Your Maps API Key &amp;quot;/&amp;gt; &amp;lt;LinearLayout android: id =&amp;quot; @ + id / zoomview &amp;quot;android: layout_width =&amp;quot; wrap_content &amp;quot;android: layout_height = &amp;quot;wrap_content&amp;quot; android: layout_alignBottom = &amp;quot;@ id / mapview&amp;quot; android: layout_centerHorizontal = &amp;quot;true &amp;quot;/&amp;gt;&amp;lt;/ RelativeLayout&amp;gt;</span></pre></td></tr></table></div>

</p>
<p>  Implementation of the android Application, found that google maps can not be displayed, please know the cause of the friend told my, thank you. </p>

	Tags: <strong><a href="http://www.ucosoft.com/tag/android" title="android" rel="tag">android</a>, <a href="http://www.ucosoft.com/tag/developed" title="developed" rel="tag">developed</a>, <a href="http://www.ucosoft.com/tag/eclipse" title="eclipse" rel="tag">eclipse</a>, <a href="http://www.ucosoft.com/tag/mapview" title="mapview" rel="tag">mapview</a>, <a href="http://www.ucosoft.com/tag/study" title="study" rel="tag">study</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/eclipse-developed-android-mapview-study-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse developed Android, TableLayout (study 4)</title>
		<link>http://www.ucosoft.com/eclipse-developed-android-tablelayout-study-2.html</link>
		<comments>http://www.ucosoft.com/eclipse-developed-android-tablelayout-study-2.html#comments</comments>
		<pubDate>Thu, 17 Dec 2009 23:52:30 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[developed]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[tablelayout]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/uncategorized/eclipse-developed-android-tablelayout-study-2.html</guid>
		<description><![CDATA[Hello, TableLayout A TableLayout is a ViewGroup that will Lay child View elements into rows and columns. Start a new project / Activity called HelloTableLayout. Open the layout file. Make it like so: 1 &#38;lt;? xml version = &#38;quot;1.0&#38;quot; encoding = &#38;quot;utf-8&#38;quot;?&#38;gt; &#38;lt;TableLayout xmlns: android = &#38;quot;http://schemas.android.com/apk/res/android&#38;quot; android: layout_width = &#38;quot;fill_parent&#38;quot; android: layout_height = &#38;quot;fill_parent&#38;quot; [...]]]></description>
			<content:encoded><![CDATA[<h1>  Hello, TableLayout </h1>
<div>
<div class="jd-descr">
<p> A <code>TableLayout</code> is a ViewGroup that will Lay child View elements into rows and columns. </p>
<ol>
<li>  Start a new project / Activity called HelloTableLayout. </li>
<li>  Open the layout file. Make it like so:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;?</span> xml version <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #cc66cc;">1.0</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> encoding <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>utf<span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;?&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>TableLayout xmlns<span style="color: #339933;">:</span> android <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//schemas.android.com/apk/res/android&amp;quot; android: layout_width = &amp;quot;fill_parent&amp;quot; android: layout_height = &amp;quot;fill_parent&amp;quot; android: stretchColumns = &amp;quot;1&amp;quot;&amp;gt; &amp;lt;TableRow&amp;gt; &amp;lt;TextView android:layout_column=&amp;quot;1&amp;quot; android:text=&amp;quot;Open...&amp;quot; android:padding=&amp;quot;3dip&amp;quot; /&amp;gt; &amp;lt;TextView android: text = &amp;quot; Ctrl-O &amp;quot;android: gravity =&amp;quot; right &amp;quot;android: padding =&amp;quot; 3dip &amp;quot;/&amp;gt; &amp;lt;/ TableRow&amp;gt; &amp;lt;TableRow&amp;gt; &amp;lt;TextView android: layout_column =&amp;quot; 1 &amp;quot;android: text =&amp;quot; Save ... &amp;quot;android: padding = &amp;quot;3dip&amp;quot; /&amp;gt; &amp;lt;TextView android:text=&amp;quot;Ctrl-S&amp;quot; android:gravity=&amp;quot;right&amp;quot; android:padding=&amp;quot;3dip&amp;quot; /&amp;gt; &amp;lt;/ TableRow&amp;gt; &amp;lt;TableRow&amp;gt; &amp;lt;TextView android: layout_column = &amp;quot;1&amp;quot; android: text = &amp;quot;Save As ...&amp;quot; android: padding = &amp;quot;3dip&amp;quot; /&amp;gt; &amp;lt;TextView android:text=&amp;quot;Ctrl-Shift-S&amp;quot; android:gravity=&amp;quot;right&amp;quot; android:padding=&amp;quot;3dip&amp;quot; /&amp;gt; &amp;lt;/ TableRow &amp;gt; &amp;lt;View android:layout_height=&amp;quot;2dip&amp;quot; android:background=&amp;quot;#FF909090&amp;quot; /&amp;gt; &amp;lt;TableRow&amp;gt; &amp;lt;TextView android:text=&amp;quot;X&amp;quot; android:padding=&amp;quot;3dip&amp;quot; /&amp;gt; &amp;lt;TextView android: text = &amp;quot;Import. .. &amp;quot;android: padding =&amp;quot; 3dip &amp;quot;/&amp;gt; &amp;lt;/ TableRow&amp;gt; &amp;lt;TableRow&amp;gt; &amp;lt;TextView android:text=&amp;quot;X&amp;quot; android:padding=&amp;quot;3dip&amp;quot; /&amp;gt; &amp;lt;TextView android: text =&amp;quot; Export ... &amp;quot;android : padding = &amp;quot;3dip&amp;quot; /&amp;gt; &amp;lt;TextView android:text=&amp;quot;Ctrl-E&amp;quot; android:gravity=&amp;quot;right&amp;quot; android:padding=&amp;quot;3dip&amp;quot; /&amp;gt; &amp;lt;/ TableRow&amp;gt; &amp;lt;View android: layout_height = &amp;quot;2dip&amp;quot; android: background = &amp;quot;# FF909090&amp;quot; /&amp;gt; &amp;lt;TableRow&amp;gt; &amp;lt;TextView android:layout_column=&amp;quot;1&amp;quot; android:text=&amp;quot;Quit&amp;quot; android:padding=&amp;quot;3dip&amp;quot; /&amp;gt; &amp;lt;/ TableRow&amp;gt; &amp;lt;/ TableLayout&amp;gt;</span></pre></td></tr></table></div>

<p>  Notice How this resembles the structure of an HTML Table. <code>TableLayout</code> is like the <code>table</code> element; <code>TableRow</code> is like a <code>tr</code> element; but for our cells like the HTML <code>td</code> element, we can use any kind of View. Here, we use <code>TextView</code> for the cells. </p>
</li>
<li>  Make sure your Activity loads this layout in the <code>onCreate()</code> method:

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <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 savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span> <span style="color: #009900;">&#40;</span>savedInstanceState<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;">&#41;</span></pre></td></tr></table></div>

<p>  <code>R.layout.main</code> refers to the <code>main.xml</code> layout file. </p>
</li>
<li>  Run it. </li>
</ol>
<p>  You should see the following: </p>
<p><img src="/images/a4f09f3d8bb6b82fc61491b306284d39.png" alt="" width="150" height="171" /></div>
</div>

	Tags: <strong><a href="http://www.ucosoft.com/tag/android" title="android" rel="tag">android</a>, <a href="http://www.ucosoft.com/tag/developed" title="developed" rel="tag">developed</a>, <a href="http://www.ucosoft.com/tag/eclipse" title="eclipse" rel="tag">eclipse</a>, <a href="http://www.ucosoft.com/tag/study" title="study" rel="tag">study</a>, <a href="http://www.ucosoft.com/tag/tablelayout" title="tablelayout" rel="tag">tablelayout</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/eclipse-developed-android-tablelayout-study-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android if they had to switch screen solution (reproduced)</title>
		<link>http://www.ucosoft.com/android-switch-screen-solution-reproduced-2.html</link>
		<comments>http://www.ucosoft.com/android-switch-screen-solution-reproduced-2.html#comments</comments>
		<pubDate>Thu, 17 Dec 2009 22:22:28 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[reproduced]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[switch]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/uncategorized/android-switch-screen-solution-reproduced-2.html</guid>
		<description><![CDATA[Original From: http://blog.sina.com.cn/s/blog_4ca975460100g5yj.html Android if they had to switch on the screen solution The time in the development of the game, some games are only horizontal screen play, so when placed in the erection of mobile phone, to keep the game screen is still horizontal screen. To achieve this requirement is very simple to configure [...]]]></description>
			<content:encoded><![CDATA[<p>  Original From: http://blog.sina.com.cn/s/blog_4ca975460100g5yj.html </p>
</p>
<p>  Android if they had to switch on the screen solution </p>
<p>  The time in the development of the game, some games are only horizontal screen play, so when placed in the erection of mobile phone, to keep the game screen is still horizontal screen.  To achieve this requirement is very simple to configure in the AndroidManifest.xml inside look on it.  Add this line android: screenOrientation = &quot;landscape&quot;. </p>
<p>  For example, (landscape is a horizontal, portrait vertical): <br />  Java code </p>
<p>  &lt;? xml version = &quot;1.0&quot; encoding = &quot;utf-8&quot;?&gt; <br />  &lt;manifest xmlns: android = &quot;http://schemas.android.com/apk/res/android&quot; <br />  package = &quot;com.ray.linkit&quot; <br />  android: versionCode = &quot;1&quot; <br />  android: versionName = &quot;1.0&quot;&gt; <br />  &lt;application android:icon=&quot;@drawable/icon&quot; android:label=&quot;@string/app_name&quot;&gt; <br />  &lt;activity android: name = &quot;. Main&quot; <br />  android: label = &quot;@ string / app_name&quot; <br />  android: screenOrientation = &quot;portrait&quot;&gt; <br />  &lt;intent-filter&gt; <br />  &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt; <br />  &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt; <br />  &lt;/ intent-filter&gt; <br />  &lt;/ activity&gt; <br />  &lt;activity android: name = &quot;. GamePlay&quot; <br />  android: screenOrientation = &quot;portrait&quot;&gt; &lt;/ activity&gt; <br />  &lt;activity android: name = &quot;. OptionView&quot; <br />  android: screenOrientation = &quot;portrait&quot;&gt; &lt;/ activity&gt; <br />  &lt;/ application&gt; <br />  &lt;uses-sdk android:minSdkVersion=&quot;3&quot; /&gt; <br />  &lt;/ manifest&gt; </p>
<p>  &lt;? xml version = &quot;1.0&quot; encoding = &quot;utf-8&quot;?&gt; <br />  &lt;manifest xmlns: android = &quot;http://schemas.android.com/apk/res/android&quot; <br />  package = &quot;com.ray.linkit&quot; <br />  android: versionCode = &quot;1&quot; <br />  android: versionName = &quot;1.0&quot;&gt; <br />  &lt;application android:icon=&quot;@drawable/icon&quot; android:label=&quot;@string/app_name&quot;&gt; <br />  &lt;activity android: name = &quot;. Main&quot; <br />  android: label = &quot;@ string / app_name&quot; <br />  android: screenOrientation = &quot;portrait&quot;&gt; <br />  &lt;intent-filter&gt; <br />  &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt; <br />  &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt; <br />  &lt;/ intent-filter&gt; <br />  &lt;/ activity&gt; <br />  &lt;activity android: name = &quot;. GamePlay&quot; <br />  android: screenOrientation = &quot;portrait&quot;&gt; &lt;/ activity&gt; <br />  &lt;activity android: name = &quot;. OptionView&quot; <br />  android: screenOrientation = &quot;portrait&quot;&gt; &lt;/ activity&gt; <br />  &lt;/ application&gt; <br />  &lt;uses-sdk android:minSdkVersion=&quot;3&quot; /&gt; <br />  &lt;/ manifest&gt; </p>
<p>  In addition, android dynamic switching each time the screen will restart Activity, so it should be in the Activity prior to their destruction to save the state of current activity in the Activity, when re-Create load configuration, as carried out in the game will not be automatically restarted! </p>
<p>  Reprinted from: http://rayleung.javaeye.com/blog/426972 </p>
<p>  Answers Time :2009-01-18 18:04 <br />  When the screen when the screen becomes horizontal, the system will re-calls the current Activity&#39;s OnCreate method, you can put on your OnCreate the following methods to check the current in the direction of, then you can let your SetContentView to load a different Layout xml. </p>
<p>  if (this.getResources (). getConfiguration (). orientation == Configuration.ORIENTATION_LANDSCAPE) ( </p>
<p>  Log.i ( &quot;info&quot;, &quot;landscape&quot;); </p>
<p>  ) </p>
<p>  else if (this.getResources (). getConfiguration (). orientation == Configuration.ORIENTATION_PORTRAIT) ( </p>
<p>  Log.i ( &quot;info&quot;, &quot;portrait&quot;); </p>
<p>  ) </p>
<p>  When switching on the screen first need to add the configuration in the androidmanifest.xml <br />  android: configChanges = &quot;orientation | keyboardHidden | navigation <br />  So in the program. Activity will not be repeated call onCreate () <br />  Does not even call onPause.onResume. <br />  Will call a onConfigurationChanged (Configuration newConfig) <br />  This is the XML configuration option to join the premise. </p>
<p>  If you join the options on the premise. As stated above. Activity will be re-activated onCreate method </p>
<p>  According to your own needs to choose the configuration changes when the mechanism for handling such a better life. </p>

	Tags: <strong><a href="http://www.ucosoft.com/tag/android" title="android" rel="tag">android</a>, <a href="http://www.ucosoft.com/tag/reproduced" title="reproduced" rel="tag">reproduced</a>, <a href="http://www.ucosoft.com/tag/screen" title="screen" rel="tag">screen</a>, <a href="http://www.ucosoft.com/tag/solution" title="solution" rel="tag">solution</a>, <a href="http://www.ucosoft.com/tag/switch" title="switch" rel="tag">switch</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/android-switch-screen-solution-reproduced-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android custom ContentProvider</title>
		<link>http://www.ucosoft.com/android-custom-contentprovider-2.html</link>
		<comments>http://www.ucosoft.com/android-custom-contentprovider-2.html#comments</comments>
		<pubDate>Thu, 17 Dec 2009 19:07:18 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[contentprovider]]></category>
		<category><![CDATA[custom]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/uncategorized/android-custom-contentprovider-2.html</guid>
		<description><![CDATA[Custom ContentProvider &#8212;&#8212;&#8212;- The content provider is used to deal with data sources, while the content parser (ContentResolver) responsible for operating the specific content provider. The data source can be a file or database. More content resolver can simultaneously access the content provider because it is thread-safe . A URI can identify a resource, and [...]]]></description>
			<content:encoded><![CDATA[<p>  Custom ContentProvider <br />  &#8212;&#8212;&#8212;- <br />  The content provider is used to deal with data sources, while the content parser (ContentResolver) responsible for operating the specific content provider. The data source can be a file or database. More content resolver can simultaneously access the content provider because it is thread-safe . <br />  A URI can identify a resource, and a content provider can have multiple URI. But all the same URI of the AUTHORITY. <br />  Android no shared memory, so to access data from another process must be through the content provider to operate the device. </p>
<p>  1. Inheritance ContentProvider, and override all abstract methods. <br />  Android OS automatically call ContentProvider of onCreate () method, while the database is on-demand enabled. </p>
<p>  2. Configuration AndroidManifest.xml <br />  &lt;provider android: authorities = &quot;tl.android.provider.bookprovider&quot; <br />  android: name = &quot;tl.android.data.TestContentProvider&quot;&gt; <br />  &lt;/ provider&gt; </p>
<p>  name: Specifies ContentProvider subclass the full class path. <br />  authorities: the specified ContentProvider unique identification (recommended: company name. provider. data table + provider) </p>
<p>  3. For the content provider defines various constants. <br />  CONTENT_URI <br />  TABLE_NAME <br />  DATABASE_NAME <br />  DATABASE_VERSION <br />  &#8230; </p>
<p>  4. ContentResolver inserting data record by </p>
<p>  5. To obtain the generated database and view <br />  *. db directory databases in the application of generally under. <br />  For example: <br />  / data / data / tl.android.apps / databases / books.db </p>
<p>  Copy Database to C: <br />  adb pull / data / data / tl.android.apps / databases / books.db c:  </p>
<p>  Will be generated books.db drag sqlite3.exe (in the Android SDK tools directory) </p>
<p>  View database tables <br />  . tables </p>
<p>  See the specific form <br />  select * from table_name; </p>
<p>  Specific reference code: <br />  TestContentProvider.java</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"> <span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">tl.android.data</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.HashMap</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">tl.android.data.TestContentProviderMetaData.BookTableMetaData</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.content.ContentProvider</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.content.ContentResolver</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.content.ContentUris</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.content</span> . <span style="color: #006633;">ContentValues</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.content.Context</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.content.UriMatcher</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.database.Cursor</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.database.SQLException</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.database.sqlite.SQLiteDatabase</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.database.sqlite.SQLiteOpenHelper</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.database.sqlite.SQLiteQueryBuilder</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.database.sqlite.SQLiteDatabase.CursorFactory</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.net.Uri</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.provider.BaseColumns</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.text.TextUtils</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.util.Log</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TestContentProvider <span style="color: #000000; font-weight: bold;">extends</span> ContentProvider <span style="color: #009900;">&#40;</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: #003399;">String</span> TAG <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>amos_tl<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;;</span> <span style="color: #000000; font-weight: bold;">public</span> DatabaseHelper openHelper <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span> <span style="color: #339933;">/</span> <span style="color: #339933;">/</span> <span style="color: #339933;">-</span> Create table column names and JavaBean map. <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">HashMap</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>String, String<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> sBookProjectionMap <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #009900;">&#40;</span>sBookProjectionMap <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">HashMap</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #003399;">String</span>, String<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> sBookProjectionMap.<span style="color: #006633;">put</span> <span style="color: #009900;">&#40;</span>BookTableMetaData._ID, BookTableMetaData._ID<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> sBookProjectionMap.<span style="color: #006633;">put</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">BOOK_NAME</span>, BookTableMetaData.<span style="color: #006633;">BOOK_NAME</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> sBookProjectionMap.<span style="color: #006633;">put</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">BOOK_ISBN</span>, BookTableMetaData.<span style="color: #006633;">BOOK_ISBN</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> sBookProjectionMap.<span style="color: #006633;">put</span> <span style="color: #009900;">&#40;</span> BookTableMetaData.<span style="color: #006633;">BOOK_AUTHOR</span>, BookTableMetaData.<span style="color: #006633;">BOOK_AUTHOR</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> sBookProjectionMap.<span style="color: #006633;">put</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">CREATED_DATE</span>, BookTableMetaData.<span style="color: #006633;">CREATED_DATE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> sBookProjectionMap.<span style="color: #006633;">put</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">MODIFIED_DATE</span>, BookTableMetaData.<span style="color: #006633;">MODIFIED_DATE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #339933;">/</span> <span style="color: #339933;">-</span> create the best match URI device <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> UriMatcher sUriMatcher <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span> <span style="color: #339933;">/</span> <span style="color: #339933;">/</span> <span style="color: #339933;">-</span> registered URI request type <span style="color: #000000; font-weight: bold;">private</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> INCOMMING_BOOK_COLLECTION_URI_INDICATOR <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">private</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> INCOMMING_SINGLE_BOOK_URI_INDICATOR <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #009900;">&#40;</span>sUriMatcher <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> UriMatcher <span style="color: #009900;">&#40;</span>UriMatcher.<span style="color: #006633;">NO_MATCH</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> sUriMatcher.<span style="color: #006633;">addURI</span> <span style="color: #009900;">&#40;</span>TestContentProviderMetaData.<span style="color: #006633;">AUTHORITY</span>, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>books<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> , INCOMMING_BOOK_COLLECTION_URI_INDICATOR<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> sUriMatcher.<span style="color: #006633;">addURI</span> <span style="color: #009900;">&#40;</span>TestContentProviderMetaData.<span style="color: #006633;">AUTHORITY</span>, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>books <span style="color: #339933;">/</span> #<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>, INCOMMING_SINGLE_BOOK_URI_INDICATOR<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> @ Overridepublic <span style="color: #000066; font-weight: bold;">int</span> delete <span style="color: #009900;">&#40;</span>Uri uri, <span style="color: #003399;">String</span> whereClause, <span style="color: #003399;">String</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> whereArgs<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>Log.<span style="color: #006633;">i</span> <span style="color: #009900;">&#40;</span>TAG, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>del<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #339933;">/</span> <span style="color: #339933;">/</span> TODO Auto<span style="color: #339933;">-</span>generated method stubSQLiteDatabase db <span style="color: #339933;">=</span> openHelper.<span style="color: #006633;">getWritableDatabase</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">int</span> count <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>sUriMatcher.<span style="color: #006633;">match</span> <span style="color: #009900;">&#40;</span>uri<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">case</span> INCOMMING_BOOK_COLLECTION_URI_INDICATOR<span style="color: #339933;">:</span> count <span style="color: #339933;">=</span> db.<span style="color: #006633;">delete</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">TABLE_NAME</span>, whereClause, whereArgs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">break</span> <span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">case</span> INCOMMING_SINGLE_BOOK_URI_INDICATOR<span style="color: #339933;">:</span> <span style="color: #003399;">String</span> rowID <span style="color: #339933;">=</span> uri.<span style="color: #006633;">getPathSegments</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">get</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #003399;">String</span> where <span style="color: #339933;">=</span> BookTableMetaData._ID <span style="color: #339933;">+</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;=&amp;</span>quot<span style="color: #339933;">;</span> <span style="color: #339933;">+</span> rowID <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> TextUtils.<span style="color: #006633;">isEmpty</span> <span style="color: #009900;">&#40;</span>whereClause<span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>AND <span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> <span style="color: #339933;">+</span> whereClause <span style="color: #339933;">+</span> <span style="color: #339933;">&amp;</span>#<span style="color: #cc66cc;">39</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;</span>#<span style="color: #cc66cc;">39</span><span style="color: #339933;">;</span> <span style="color: #339933;">:&amp;</span>quot<span style="color: #339933;">;&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> count <span style="color: #339933;">=</span> db.<span style="color: #006633;">delete</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">TABLE_NAME</span>, where, whereArgs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">IllegalArgumentException</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>Unknown URI<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> <span style="color: #339933;">+</span> uri<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getContext</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">getContentResolver</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">notifyChange</span> <span style="color: #009900;">&#40;</span>uri , <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">return</span> count<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> @ Overridepublic <span style="color: #003399;">String</span> getType <span style="color: #009900;">&#40;</span>Uri uri<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>sUriMatcher.<span style="color: #006633;">match</span> <span style="color: #009900;">&#40;</span>uri<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">case</span> INCOMMING_BOOK_COLLECTION_URI_INDICATOR<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">return</span> BookTableMetaData.<span style="color: #006633;">CONTENT_TYPE</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">case</span> INCOMMING_SINGLE_BOOK_URI_INDICATOR<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">return</span> BookTableMetaData.<span style="color: #006633;">CONTENT_ITEM_TYPE</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">IllegalArgumentException</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> Unknown URI <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;+</span> uri <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span>Overridepublic Uri insert <span style="color: #009900;">&#40;</span>Uri uri, ContentValues values<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span> <span style="color: #339933;">/</span> TODO Auto<span style="color: #339933;">-</span>generated method stubLog.<span style="color: #006633;">i</span> <span style="color: #009900;">&#40;</span>TAG,<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> insert <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>sUriMatcher.<span style="color: #006633;">match</span> <span style="color: #009900;">&#40;</span>uri<span style="color: #009900;">&#41;</span><span style="color: #339933;">!</span> <span style="color: #339933;">=</span> INCOMMING_BOOK_COLLECTION_URI_INDICATOR <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">IllegalArgumentException</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>Unknown URI<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> <span style="color: #339933;">+</span> uri<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">long</span> now <span style="color: #339933;">=</span> <span style="color: #003399;">Long</span>.<span style="color: #006633;">valueOf</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>values.<span style="color: #006633;">containsKey</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">CREATED_DATE</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>values.<span style="color: #006633;">put</span> <span style="color: #009900;">&#40;</span>BookTableMetaData. <span style="color: #006633;">CREATED_DATE</span>, now<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>values.<span style="color: #006633;">containsKey</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">MODIFIED_DATE</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>values.<span style="color: #006633;">put</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">MODIFIED_DATE</span>, now<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>values.<span style="color: #006633;">containsKey</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">BOOK_NAME</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span> <span style="color: #339933;">/</span> values.<span style="color: #006633;">put</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">BOOK_NAME</span>, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>null<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">SQLException</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>Failed to insert row, because <span style="color: #003399;">Book</span> <span style="color: #003399;">Name</span> is needed<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> <span style="color: #339933;">+</span> uri<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>values.<span style="color: #006633;">containsKey</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">BOOK_ISBN</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>values . <span style="color: #006633;">put</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">BOOK_ISBN</span>, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>Unknown ISBN<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>values.<span style="color: #006633;">containsKey</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">BOOK_AUTHOR</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>values.<span style="color: #006633;">put</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">BOOK_AUTHOR</span>, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>Unknown author<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> SQLiteDatabase db <span style="color: #339933;">=</span> openHelper.<span style="color: #006633;">getWritableDatabase</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">long</span> rowID <span style="color: #339933;">=</span> db.<span style="color: #006633;">insert</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">TABLE_NAME</span>, BookTableMetaData.<span style="color: #006633;">BOOK_NAME</span>, values<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>rowID<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>Uri insertBookedUri <span style="color: #339933;">=</span> ContentUris.<span style="color: #006633;">withAppendedId</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">CONTENT_URI</span>, rowID<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> getContext <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">getContentResolver</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">notifyChange</span> <span style="color: #009900;">&#40;</span>insertBookedUri, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">return</span> insertBookedUri<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">SQLException</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>Failed to insert row into<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> <span style="color: #339933;">+</span> uri<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> @ Overridepublic <span style="color: #000066; font-weight: bold;">boolean</span> onCreate <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span> <span style="color: #339933;">/</span> TODO Auto<span style="color: #339933;">-</span>generated method stubLog.<span style="color: #006633;">i</span> <span style="color: #009900;">&#40;</span>TAG, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>create table <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> openHelper <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DatabaseHelper <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getContext</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> Log.<span style="color: #006633;">i</span> <span style="color: #009900;">&#40;</span>TAG, openHelper.<span style="color: #006633;">toString</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> @ Overridepublic <span style="color: #003399;">Cursor</span> query <span style="color: #009900;">&#40;</span>Uri uri, <span style="color: #003399;">String</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> projection, <span style="color: #003399;">String</span> selection, <span style="color: #003399;">String</span> <span style="color: #009900;">&#91;</span> <span style="color: #009900;">&#93;</span> selectionArgs, <span style="color: #003399;">String</span> sortOrder<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span> <span style="color: #339933;">/</span> TODO Auto<span style="color: #339933;">-</span>generated method stubLog.<span style="color: #006633;">i</span> <span style="color: #009900;">&#40;</span>TAG, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>query<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #003399;">Cursor</span> cursor <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span> SQLiteQueryBuilder qb <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span> qb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SQLiteQueryBuilder <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>sUriMatcher.<span style="color: #006633;">match</span> <span style="color: #009900;">&#40;</span>uri<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">case</span> INCOMMING_BOOK_COLLECTION_URI_INDICATOR<span style="color: #339933;">:</span> qb.<span style="color: #006633;">setTables</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">TABLE_NAME</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> qb.<span style="color: #006633;">setProjectionMap</span> <span style="color: #009900;">&#40;</span>sBookProjectionMap<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">case</span> INCOMMING_SINGLE_BOOK_URI_INDICATOR<span style="color: #339933;">:</span> qb.<span style="color: #006633;">setTables</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">TABLE_NAME</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> qb.<span style="color: #006633;">setProjectionMap</span> <span style="color: #009900;">&#40;</span>sBookProjectionMap<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> qb.<span style="color: #006633;">appendWhere</span> <span style="color: #009900;">&#40;</span>BookTableMetaData._ID <span style="color: #339933;">+</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;=&amp;</span>quot<span style="color: #339933;">;</span> <span style="color: #339933;">+</span> uri.<span style="color: #006633;">getPathSegments</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">get</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">IllegalArgumentException</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>Unknown URI<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> <span style="color: #339933;">+</span> uri<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #003399;">String</span> orderBy <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;&amp;</span>quot<span style="color: #339933;">;;</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>TextUtils.<span style="color: #006633;">isEmpty</span> <span style="color: #009900;">&#40;</span>sortOrder<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>orderBy <span style="color: #339933;">=</span> BookTableMetaData.<span style="color: #006633;">DEFAULT_SORT_ORDER</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#40;</span>orderBy <span style="color: #339933;">=</span> sortOrder<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> SQLiteDatabase db <span style="color: #339933;">=</span> openHelper.<span style="color: #006633;">getReadableDatabase</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #003399;">Cursor</span> c <span style="color: #339933;">=</span> qb.<span style="color: #006633;">query</span> <span style="color: #009900;">&#40;</span>db, projection, selection, selectionArgs, <span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #000066; font-weight: bold;">null</span>, orderBy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> c.<span style="color: #006633;">getCount</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> ContentResolver cr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getContext</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">getContentResolver</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> c.<span style="color: #006633;">setNotificationUri</span> <span style="color: #009900;">&#40;</span>cr, uri<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">return</span> c<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> @ Overridepublic <span style="color: #000066; font-weight: bold;">int</span> update <span style="color: #009900;">&#40;</span>Uri uri, ContentValues values, <span style="color: #003399;">String</span> selection, <span style="color: #003399;">String</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> selectionArgs<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span> <span style="color: #339933;">/</span> TODO Auto<span style="color: #339933;">-</span>generated method stubLog.<span style="color: #006633;">i</span> <span style="color: #009900;">&#40;</span>TAG, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>update<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> SQLiteDatabase db <span style="color: #339933;">=</span> openHelper.<span style="color: #006633;">getWritableDatabase</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">int</span> count <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>sUriMatcher.<span style="color: #006633;">match</span> <span style="color: #009900;">&#40;</span>uri<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">case</span> INCOMMING_BOOK_COLLECTION_URI_INDICATOR<span style="color: #339933;">:</span> count <span style="color: #339933;">=</span> db.<span style="color: #006633;">update</span> <span style="color: #009900;">&#40;</span> BookTableMetaData.<span style="color: #006633;">TABLE_NAME</span>, values, selection, selectionArgs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">case</span> INCOMMING_SINGLE_BOOK_URI_INDICATOR<span style="color: #339933;">:</span> <span style="color: #003399;">String</span> rowID <span style="color: #339933;">=</span> uri.<span style="color: #006633;">getPathSegments</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">get</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #003399;">String</span> where <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>BookTableMetaData._ID<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> <span style="color: #339933;">+</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;=&amp;</span>quot<span style="color: #339933;">;</span> <span style="color: #339933;">+</span> rowID <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> TextUtils.<span style="color: #006633;">isEmpty</span> <span style="color: #009900;">&#40;</span>selection<span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>AND <span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> <span style="color: #339933;">+</span> selection <span style="color: #339933;">+&amp;</span>#<span style="color: #cc66cc;">39</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;</span>#<span style="color: #cc66cc;">39</span><span style="color: #339933;">;:&amp;</span>quot<span style="color: #339933;">;&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> count <span style="color: #339933;">=</span> db.<span style="color: #006633;">update</span> <span style="color: #009900;">&#40;</span>BookTableMetaData.<span style="color: #006633;">TABLE_NAME</span>, values, where, selectionArgs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">IllegalArgumentException</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>Unknown URI<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> <span style="color: #339933;">+</span> uri <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> getContext <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">getContentResolver</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">notifyChange</span> <span style="color: #009900;">&#40;</span>uri, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">return</span> count <span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//-- create tablepublic class DatabaseHelper extends SQLiteOpenHelper (public DatabaseHelper (Context context) (super (context, TestContentProviderMetaData.DATABASE_NAME, null, TestContentProviderMetaData.DATABASE_VERSION);) @ Overridepublic void onCreate (SQLiteDatabase db) (/ / TODO Auto-generated method stubString sql = &amp;quot;CREATE TABLE&amp;quot; + BookTableMetaData.TABLE_NAME + &amp;quot;(&amp;quot; + TestContentProviderMetaData.BookTableMetaData._ID + &amp;quot;INTEGER PRIMARY KEY,&amp;quot; + BookTableMetaData.BOOK_NAME + &amp;quot;TEXT,&amp;quot; + BookTableMetaData.BOOK_ISBN + &amp;quot;TEXT,&amp;quot; + BookTableMetaData.BOOK_AUTHOR + &amp;quot;TEXT,&amp;quot; + BookTableMetaData.CREATED_DATE + &amp;quot;INTEGER,&amp;quot; + BookTableMetaData.MODIFIED_DATE + &amp;quot;INTEGER&amp;quot; + &amp;quot;);&amp;quot;; Log . i (TAG, db.getPath ()); db.execSQL (sql);) @ Overridepublic void onUpgrade (SQLiteDatabase db, int oldVersion, int newVersion) (/ / TODO Auto-generated method stubLog.i (TAG, &amp;quot;Upgrade database from &amp;quot;+ oldVersion +&amp;quot; to &amp;quot;+ newVersion +&amp;quot;, which will destroy old data! &amp;quot;); String sql =&amp;quot; DROP TABLE IF EXISTS &amp;quot;+ BookTableMetaData.TABLE_NAME; db.execSQL (sql); onCreate (db);) )) class TestContentProviderMetaData (public static final String DATABASE_NAME = &amp;quot;books.db&amp;quot;; public static final int DATABASE_VERSION = 1; public static final String AUTHORITY = &amp;quot;tl.android.provider.bookprovider&amp;quot;; public static final String BOOKS_TABLE_NAME = &amp;quot;books&amp;quot; ; public static final class BookTableMetaData implements BaseColumns (public static final String TABLE_NAME = &amp;quot;books&amp;quot;; / / String public static final String BOOK_NAME = &amp;quot;name&amp;quot;; / / Stringpublic static final String BOOK_ISBN = &amp;quot;isbn&amp;quot;; / / Stringpublic static final String BOOK_AUTHOR = &amp;quot;author&amp;quot;; / / Integerpublic static final String CREATED_DATE = &amp;quot;created&amp;quot;; / / Integerpublic static final String MODIFIED_DATE = &amp;quot;modified&amp;quot;; public static final Uri CONTENT_URI = Uri.parse ( &amp;quot;content: / /&amp;quot; + AUTHORITY + &amp;quot; / books &amp;quot;);//-- multi-record public static final String CONTENT_TYPE = &amp;quot;vnd.android.cursor.dir / vnd.androidbook.book &amp;quot;;//-- a single record of public static final String CONTENT_ITEM_TYPE =&amp;quot; vnd.android. cursor.item / vnd.androidbook.book &amp;quot;; public static final String DEFAULT_SORT_ORDER =&amp;quot; modified DESC &amp;quot;;))</span></pre></td></tr></table></div>

<p>  MainActivity.java</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">tl.android.apps</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">tl.android.data.TestContentProvider</span><span style="color: #339933;">;</span> <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.content.ContentResolver</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.content.ContentValues</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.database.sqlite.SQLiteDatabase</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.os</span> . <span style="color: #006633;">Bundle</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MainActivity <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span> <span style="color: #339933;">**</span> Called when the activity is first created. <span style="color: #339933;">*</span> <span style="color: #339933;">/</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 savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span> <span style="color: #009900;">&#40;</span>savedInstanceState<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> ContentResolver cr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getContentResolver</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> ContentValues cv <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ContentValues <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> cv.<span style="color: #006633;">put</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>name<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>android pro<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> cr.<span style="color: #006633;">insert</span> <span style="color: #009900;">&#40;</span>TestContentProvider.<span style="color: #006633;">CONTENT_URI</span>, cv<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> cv.<span style="color: #006633;">put</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>name<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>android programming <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> cr.<span style="color: #006633;">insert</span> <span style="color: #009900;">&#40;</span>TestContentProvider.<span style="color: #006633;">CONTENT_URI</span>, cv<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>  AndroidManifest.xml</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;?</span> xml version <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #cc66cc;">1.0</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> encoding <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>utf<span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;?&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>manifest xmlns<span style="color: #339933;">:</span> android <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//schemas.android.com/apk/res/android&amp;quot; package = &amp;quot;tl.android.apps&amp;quot; android : versionCode = &amp;quot;1&amp;quot; android: versionName = &amp;quot;1.0&amp;quot;&amp;gt; &amp;lt;application android:icon=&amp;quot;@drawable/icon&amp;quot; android:label=&amp;quot;@string/app_name&amp;quot;&amp;gt; &amp;lt;activity android: name = &amp;quot;tl.android.apps. MainActivity &amp;quot;android: label =&amp;quot; @ string / app_name &amp;quot;&amp;gt; &amp;lt;intent-filter&amp;gt; &amp;lt;action android:name=&amp;quot;android.intent.action.MAIN&amp;quot; /&amp;gt; &amp;lt;category android: name =&amp;quot; android.intent.category.LAUNCHER &amp;quot; /&amp;gt; &amp;lt;/ intent-filter&amp;gt; &amp;lt;/ activity&amp;gt; &amp;lt;provider android:authorities=&amp;quot;tl.android.provider.bookprovider&amp;quot;android:name=&amp;quot;tl.android.data.TestContentProvider&amp;quot;&amp;gt; &amp;lt;/ provider&amp;gt; &amp;lt;/ application&amp;gt; &amp;lt; uses-sdk android: minSdkVersion = &amp;quot;4&amp;quot; /&amp;gt; &amp;lt;/ manifest&amp;gt;</span></pre></td></tr></table></div>
</p>

	Tags: <strong><a href="http://www.ucosoft.com/tag/android" title="android" rel="tag">android</a>, <a href="http://www.ucosoft.com/tag/contentprovider" title="contentprovider" rel="tag">contentprovider</a>, <a href="http://www.ucosoft.com/tag/custom" title="custom" rel="tag">custom</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/android-custom-contentprovider-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse developed Android, Hello FormStuff (study 9)</title>
		<link>http://www.ucosoft.com/eclipse-developed-android-formstuff-study-2.html</link>
		<comments>http://www.ucosoft.com/eclipse-developed-android-formstuff-study-2.html#comments</comments>
		<pubDate>Thu, 17 Dec 2009 15:57:10 +0000</pubDate>
		<dc:creator>support</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[developed]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[formstuff]]></category>
		<category><![CDATA[study]]></category>

		<guid isPermaLink="false">http://www.ucosoft.com/uncategorized/eclipse-developed-android-formstuff-study-2.html</guid>
		<description><![CDATA[1 HelloFormStuff. Java code is as follows 1 package com.example.test; import android.app.Activity; import android.os.Bundle; import android.view.KeyEvent; import android.view.View; import android.widget.CheckBox; import android.widget.EditText; import android.widget.ImageButton; import android.widget.RadioButton; import android.widget.Toast; import android.widget.ToggleButton; public class HelloFormStuff extends Activity &#40;/ ** Called when the activity is first created. * / @ Override public void onCreate &#40;Bundle savedInstanceState&#41; &#40;super.onCreate &#40;savedInstanceState&#41;; [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  HelloFormStuff. <span style="color: #006633;">Java</span> code is as follows</pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.example.test</span><span style="color: #339933;">;</span> <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> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.KeyEvent</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.View</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.CheckBox</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.EditText</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.ImageButton</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.RadioButton</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.Toast</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.ToggleButton</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HelloFormStuff <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span> <span style="color: #339933;">**</span> Called when the activity is first created. <span style="color: #339933;">*</span> <span style="color: #339933;">/</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 savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span> <span style="color: #009900;">&#40;</span>savedInstanceState<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: #000000; font-weight: bold;">final</span> ImageButton button <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ImageButton<span style="color: #009900;">&#41;</span> findViewById <span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">android_button</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> button.<span style="color: #006633;">setOnClickListener</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">View</span>.<span style="color: #006633;">OnClickListener</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onClick <span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> v<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span> <span style="color: #339933;">/</span> Perform action on clicks Toast.<span style="color: #006633;">makeText</span> <span style="color: #009900;">&#40;</span>HelloFormStuff.<span style="color: #000000; font-weight: bold;">this</span>, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>Beep Bop<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>, Toast.<span style="color: #006633;">LENGTH_SHORT</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">show</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">final</span> EditText edittext <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>EditText<span style="color: #009900;">&#41;</span> findViewById <span style="color: #009900;">&#40;</span>R. <span style="color: #006633;">id</span>.<span style="color: #006633;">edittext</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> edittext.<span style="color: #006633;">setOnKeyListener</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">View</span>.<span style="color: #006633;">OnKeyListener</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onKey <span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> v, <span style="color: #000066; font-weight: bold;">int</span> keyCode, <span style="color: #003399;">KeyEvent</span> event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">getAction</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #003399;">KeyEvent</span>.<span style="color: #006633;">ACTION_DOWN</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span>keyCode <span style="color: #339933;">==</span> <span style="color: #003399;">KeyEvent</span> . <span style="color: #006633;">KEYCODE_ENTER</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span> <span style="color: #339933;">/</span> Perform action on key press Toast.<span style="color: #006633;">makeText</span> <span style="color: #009900;">&#40;</span>HelloFormStuff.<span style="color: #000000; font-weight: bold;">this</span>, edittext.<span style="color: #006633;">getText</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, Toast.<span style="color: #006633;">LENGTH_SHORT</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">show</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">final</span> CheckBox checkbox <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>CheckBox<span style="color: #009900;">&#41;</span> findViewById <span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">checkbox</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> checkbox.<span style="color: #006633;">setOnClickListener</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">View</span>.<span style="color: #006633;">OnClickListener</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onClick <span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> v<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span> <span style="color: #339933;">/</span> Perform action on clicks <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>checkbox.<span style="color: #006633;">isChecked</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>Toast.<span style="color: #006633;">makeText</span> <span style="color: #009900;">&#40;</span> HelloFormStuff.<span style="color: #000000; font-weight: bold;">this</span>, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>Selected<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>, Toast.<span style="color: #006633;">LENGTH_SHORT</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">show</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#40;</span>Toast.<span style="color: #006633;">makeText</span> <span style="color: #009900;">&#40;</span>HelloFormStuff.<span style="color: #000000; font-weight: bold;">this</span>, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>Not selected<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>, Toast.<span style="color: #006633;">LENGTH_SHORT</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">show</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #003399;">View</span>.<span style="color: #006633;">OnClickListener</span> radio_listener <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">View</span>.<span style="color: #006633;">OnClickListener</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onClick <span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> v<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span> <span style="color: #339933;">/</span> Perform action on clicks RadioButton rb <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>RadioButton<span style="color: #009900;">&#41;</span> v<span style="color: #339933;">;</span> Toast.<span style="color: #006633;">makeText</span> <span style="color: #009900;">&#40;</span>HelloFormStuff.<span style="color: #000000; font-weight: bold;">this</span>, rb.<span style="color: #006633;">getText</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, Toast.<span style="color: #006633;">LENGTH_SHORT</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">show</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">final</span> RadioButton radio_red <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>RadioButton<span style="color: #009900;">&#41;</span> findViewById <span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">radio_red</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">final</span> RadioButton radio_blue <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>RadioButton<span style="color: #009900;">&#41;</span> findViewById <span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">radio_blue</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> radio_red.<span style="color: #006633;">setOnClickListener</span> <span style="color: #009900;">&#40;</span>radio_listener<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> radio_blue.<span style="color: #006633;">setOnClickListener</span> <span style="color: #009900;">&#40;</span> radio_listener<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">final</span> ToggleButton togglebutton <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ToggleButton<span style="color: #009900;">&#41;</span> findViewById <span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">togglebutton</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> togglebutton.<span style="color: #006633;">setOnClickListener</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">View</span>.<span style="color: #006633;">OnClickListener</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onClick <span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> v<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span> <span style="color: #339933;">/</span> Perform action on clicks <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>togglebutton.<span style="color: #006633;">isChecked</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>Toast.<span style="color: #006633;">makeText</span> <span style="color: #009900;">&#40;</span>HelloFormStuff.<span style="color: #000000; font-weight: bold;">this</span>, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>ON<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>, Toast.<span style="color: #006633;">LENGTH_SHORT</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">show</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#40;</span>Toast.<span style="color: #006633;">makeText</span> <span style="color: #009900;">&#40;</span>HelloFormStuff.<span style="color: #000000; font-weight: bold;">this</span>, <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>OFF<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>, Toast.<span style="color: #006633;">LENGTH_SHORT</span><span style="color: #009900;">&#41;</span>. <span style="color: #006633;">show</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

</p>
<p>  layout-&gt; main.xml </p>
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;?</span> xml version <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #cc66cc;">1.0</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span> encoding <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>utf<span style="color: #339933;">-</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;?&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>LinearLayout xmlns<span style="color: #339933;">:</span> android <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//schemas.android.com/apk/res/android&amp;quot; android: orientation = &amp;quot;vertical&amp;quot; android: layout_width = &amp;quot;fill_parent&amp;quot; android: layout_height = &amp;quot;fill_parent&amp;quot;&amp;gt; &amp;lt;ImageButton android: id = &amp;quot;@ + id / android_button&amp;quot; android: layout_width = &amp;quot;100dip&amp;quot; android: layout_height = &amp;quot;wrap_content&amp;quot; android: src = &amp;quot;@ drawable / android&amp;quot; / &amp;gt; &amp;lt;EditText android:id=&amp;quot;@+id/edittext&amp;quot; android:layout_width=&amp;quot;fill_parent&amp;quot; android:layout_height=&amp;quot;wrap_content&amp;quot;/&amp;gt; &amp;lt;CheckBox android: id = &amp;quot;@ + id / checkbox&amp;quot; android: layout_width = &amp;quot;wrap_content&amp;quot; android: layout_height = &amp;quot;wrap_content&amp;quot; android: text = &amp;quot;check it out&amp;quot; /&amp;gt; &amp;lt;RadioGroup android:layout_width=&amp;quot;fill_parent&amp;quot; android:layout_height=&amp;quot;wrap_content&amp;quot; android:orientation=&amp;quot;vertical&amp;quot;&amp;gt; &amp;lt;RadioButton android: id = &amp;quot;@ + id / radio_red &amp;quot;android: layout_width =&amp;quot; wrap_content &amp;quot;android: layout_height =&amp;quot; wrap_content &amp;quot;android: text =&amp;quot; Red &amp;quot;/&amp;gt; &amp;lt;RadioButton android: id =&amp;quot; @ + id / radio_blue &amp;quot;android: layout_width =&amp;quot; wrap_content &amp;quot;android: layout_height = &amp;quot;wrap_content&amp;quot; android: text = &amp;quot;Blue&amp;quot; /&amp;gt; &amp;lt;/ RadioGroup&amp;gt; &amp;lt;ToggleButton android:id=&amp;quot;@+id/togglebutton&amp;quot; android:layout_width=&amp;quot;wrap_content&amp;quot; android:layout_height=&amp;quot;wrap_content&amp;quot; /&amp;gt; &amp;lt;/ LinearLayout &amp;quot;</span></pre></td></tr></table></div>

</p>
<p>  run it as follows: </p>
<p><img src="/images/17560203d400e504d9308ef0bd1da114.png" alt="" /></p>

	Tags: <strong><a href="http://www.ucosoft.com/tag/android" title="android" rel="tag">android</a>, <a href="http://www.ucosoft.com/tag/developed" title="developed" rel="tag">developed</a>, <a href="http://www.ucosoft.com/tag/eclipse" title="eclipse" rel="tag">eclipse</a>, <a href="http://www.ucosoft.com/tag/formstuff" title="formstuff" rel="tag">formstuff</a>, <a href="http://www.ucosoft.com/tag/study" title="study" rel="tag">study</a></strong><br />
]]></content:encoded>
			<wfw:commentRss>http://www.ucosoft.com/eclipse-developed-android-formstuff-study-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

