tag:blogger.com,1999:blog-37175955207519510332024-03-18T20:36:56.283-07:00Hardik NadiyaparaAndroid Application Developer.Anonymoushttp://www.blogger.com/profile/06071431205366911491noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-3717595520751951033.post-36932477556599431142015-07-15T22:14:00.002-07:002015-07-15T22:14:34.311-07:00Ninja Balloon Fight<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXM5wYjB2y27M5QbmT-MM-eS2624lJEeRpHyAWb6ScfE_ufvFqhhhyphenhyphenl-iIUqrg74WaCNAmqKlAYuJQRZOF8VdAxAIrGuz4hV_Rx-zkgo884pU1cX0ATX4hAnrzI3E3vL3-I-woAxSOADRM/s1600/promotional_image.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="156" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXM5wYjB2y27M5QbmT-MM-eS2624lJEeRpHyAWb6ScfE_ufvFqhhhyphenhyphenl-iIUqrg74WaCNAmqKlAYuJQRZOF8VdAxAIrGuz4hV_Rx-zkgo884pU1cX0ATX4hAnrzI3E3vL3-I-woAxSOADRM/s320/promotional_image.png" width="320" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<br /></div>
<div>
We are glad to announce our first game in tha google play store free of cost. Ninja Balloon Fight<br />
<br />
<br />
<br />
Story:</div>
<div>
<span style="background-color: white; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px;">Once somewhere in the world there Zombie dominance are increasing day by day.</span><br />
<span style="background-color: white; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px;">and one day Zombies reached to your homeland</span><br />
<span style="background-color: white; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px;">you have to stop them from your homeland dominance and save your homeland</span></div>
<div style="background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 16px; padding: 0px;">
Zombies spirit is in his balloon if you pop their balloon Zombie’s spirit release and he died.<br />
for killing Zombie, you have to fly in the air and you have also a 2 balloons with you to help you for flying.</div>
<div style="background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 16px; padding: 0px;">
Zombie become more and more powerful level by level.</div>
<div style="background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 16px; padding: 0px;">
save your homeland from the Zombie dominance.</div>
<div style="background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 16px; padding: 0px;">
collect stars per level and unlock next Levels</div>
<div style="background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 16px; padding: 0px;">
★★★★★ 30 levels<br />
★★★★★ Free to play<br />
★★★★★ amazing graphics and sounds<br />
★★★★★ challenging game play<br />
★★★★★ Social sharing</div>
<div style="background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 16px; padding: 0px;">
<br /></div>
<div style="background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 16px; padding: 0px;">
Download from Google PlayStore and share your review with us.. :)</div>
<div style="background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 16px; padding: 0px;">
<a href="https://play.google.com/store/apps/details?id=com.crazygamerz.ninjaballoonfight">https://play.google.com/store/apps/details?id=com.crazygamerz.ninjaballoonfight</a></div>
</div>
Anonymoushttp://www.blogger.com/profile/06071431205366911491noreply@blogger.com0tag:blogger.com,1999:blog-3717595520751951033.post-72952976401845613802013-07-01T00:00:00.001-07:002013-07-01T00:00:11.491-07:00Calculate UTC in AndroidHello Readers,<br />
<div>
<br />
<div>
After A long Time I am restart My Blogging and add one more Tutorial about UTC.</div>
<div>
OK first we have to know about utc and how it works. for That you have to visit the following page </div>
<div>
about <a href="http://en.wikipedia.org/wiki/Coordinated_Universal_Time" target="_blank">UTC</a> </div>
</div>
<div>
<br /></div>
<div>
Now We Move to Android Side and see that how android calculate UTC.</div>
<div>
<br /></div>
<div>
first of all I assume that u have A basic Knowledge of Android Programming , Eclipse and all its related Stuff.</div>
<div>
<br />
And Below you see the some images of final out put of your application.<span id="goog_288500433"></span><span id="goog_288500434"></span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2h8FqTw8cJ9lKzNvnz_qeRLHWqX88osZ7O6SfcH0FQSF7qGInTDn13Ge8jJLOwZQ3u5Ra-ZKOw2ioRoQrjEhd2OlWY7XUH7wo8g3QEIV_dfvXfQb1BhZ_9mFBQAmTd4B1Ymel4mlvZbXm/s854/device-2013-07-01-115951.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2h8FqTw8cJ9lKzNvnz_qeRLHWqX88osZ7O6SfcH0FQSF7qGInTDn13Ge8jJLOwZQ3u5Ra-ZKOw2ioRoQrjEhd2OlWY7XUH7wo8g3QEIV_dfvXfQb1BhZ_9mFBQAmTd4B1Ymel4mlvZbXm/s854/device-2013-07-01-115951.png" height="320" width="179" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieXRx-Imdh5npioZoAbf_AQKfVg0u5yRHIJFsmwppVfB8po5JGT2dZWcAqENlXBCwms3TMrk3zPag3pV1dL78cqd5LQecHersjppumuX2LjxH0C4UtSBaV4euJaC5qPGrKE4L_rFQypP6f/s854/device-2013-07-01-120344.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieXRx-Imdh5npioZoAbf_AQKfVg0u5yRHIJFsmwppVfB8po5JGT2dZWcAqENlXBCwms3TMrk3zPag3pV1dL78cqd5LQecHersjppumuX2LjxH0C4UtSBaV4euJaC5qPGrKE4L_rFQypP6f/s854/device-2013-07-01-120344.png" height="320" width="179" /></a></div>
<br />
and Related Code I pasted below<br />
<br />
<br /></div>
<div>
<br /></div>
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;">
<table><tbody>
<tr><td><pre style="line-height: 125%; margin: 0;"> 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256</pre>
</td><td><pre style="line-height: 125%; margin: 0;"><span style="color: #008800; font-weight: bold;">package</span> com<span style="color: #333333;">.</span><span style="color: #0000cc;">example</span><span style="color: #333333;">.</span><span style="color: #0000cc;">utctime</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.text.ParseException</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.text.SimpleDateFormat</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.ArrayList</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.Calendar</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.Date</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">java.util.TimeZone</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.app.Activity</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.app.DatePickerDialog</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.app.Dialog</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.os.Bundle</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.view.Menu</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.view.View</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.view.View.OnClickListener</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.widget.AdapterView</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.widget.AdapterView.OnItemSelectedListener</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.widget.ArrayAdapter</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.widget.Button</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.widget.DatePicker</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.widget.EditText</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.widget.Spinner</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">import</span> <span style="color: #0e84b5; font-weight: bold;">android.widget.Toast</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">MainActivity</span> <span style="color: #008800; font-weight: bold;">extends</span> Activity <span style="color: #008800; font-weight: bold;">implements</span> OnClickListener <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">final</span> String DATEFORMAT <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"yyyy-MM-dd HH:mm"</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> EditText mDateDisplay<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> Button calImage<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> mYear<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> mMonth<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">int</span> mDay<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> Spinner hhSpinner<span style="color: #333333;">,</span> mmSpinner<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> EditText etUtc<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> Spinner spTimeZone<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #008800; font-weight: bold;">static</span> <span style="color: #008800; font-weight: bold;">final</span> <span style="color: #333399; font-weight: bold;">int</span> DATE_DIALOG_ID <span style="color: #333333;">=</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String selectedZone<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String selectedHours<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String selectedMinute<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> String selectedDate<span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">private</span> Date date1 <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">protected</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">onCreate</span><span style="color: #333333;">(</span>Bundle savedInstanceState<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">super</span><span style="color: #333333;">.</span><span style="color: #0000cc;">onCreate</span><span style="color: #333333;">(</span>savedInstanceState<span style="color: #333333;">);</span>
setContentView<span style="color: #333333;">(</span>R<span style="color: #333333;">.</span><span style="color: #0000cc;">layout</span><span style="color: #333333;">.</span><span style="color: #0000cc;">activity_main</span><span style="color: #333333;">);</span>
mDateDisplay <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>EditText<span style="color: #333333;">)</span> findViewById<span style="color: #333333;">(</span>R<span style="color: #333333;">.</span><span style="color: #0000cc;">id</span><span style="color: #333333;">.</span><span style="color: #0000cc;">etDateTime</span><span style="color: #333333;">);</span>
etUtc <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>EditText<span style="color: #333333;">)</span> findViewById<span style="color: #333333;">(</span>R<span style="color: #333333;">.</span><span style="color: #0000cc;">id</span><span style="color: #333333;">.</span><span style="color: #0000cc;">etUtc</span><span style="color: #333333;">);</span>
calImage <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>Button<span style="color: #333333;">)</span> findViewById<span style="color: #333333;">(</span>R<span style="color: #333333;">.</span><span style="color: #0000cc;">id</span><span style="color: #333333;">.</span><span style="color: #0000cc;">imgCal</span><span style="color: #333333;">);</span>
calImage<span style="color: #333333;">.</span><span style="color: #0000cc;">setOnClickListener</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">final</span> Calendar c <span style="color: #333333;">=</span> Calendar<span style="color: #333333;">.</span><span style="color: #0000cc;">getInstance</span><span style="color: #333333;">();</span>
mYear <span style="color: #333333;">=</span> c<span style="color: #333333;">.</span><span style="color: #0000cc;">get</span><span style="color: #333333;">(</span>Calendar<span style="color: #333333;">.</span><span style="color: #0000cc;">YEAR</span><span style="color: #333333;">);</span>
mMonth <span style="color: #333333;">=</span> c<span style="color: #333333;">.</span><span style="color: #0000cc;">get</span><span style="color: #333333;">(</span>Calendar<span style="color: #333333;">.</span><span style="color: #0000cc;">MONTH</span><span style="color: #333333;">);</span>
mDay <span style="color: #333333;">=</span> c<span style="color: #333333;">.</span><span style="color: #0000cc;">get</span><span style="color: #333333;">(</span>Calendar<span style="color: #333333;">.</span><span style="color: #0000cc;">DAY_OF_MONTH</span><span style="color: #333333;">);</span>
spTimeZone <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>Spinner<span style="color: #333333;">)</span> findViewById<span style="color: #333333;">(</span>R<span style="color: #333333;">.</span><span style="color: #0000cc;">id</span><span style="color: #333333;">.</span><span style="color: #0000cc;">spTimeZone</span><span style="color: #333333;">);</span>
hhSpinner <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>Spinner<span style="color: #333333;">)</span> findViewById<span style="color: #333333;">(</span>R<span style="color: #333333;">.</span><span style="color: #0000cc;">id</span><span style="color: #333333;">.</span><span style="color: #0000cc;">spHH</span><span style="color: #333333;">);</span>
hhSpinner<span style="color: #333333;">.</span><span style="color: #0000cc;">setOnItemSelectedListener</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> hhItemSelectedListener<span style="color: #333333;">());</span>
hhSpinner<span style="color: #333333;">.</span><span style="color: #0000cc;">requestFocus</span><span style="color: #333333;">();</span>
mmSpinner <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>Spinner<span style="color: #333333;">)</span> findViewById<span style="color: #333333;">(</span>R<span style="color: #333333;">.</span><span style="color: #0000cc;">id</span><span style="color: #333333;">.</span><span style="color: #0000cc;">spMM</span><span style="color: #333333;">);</span>
mmSpinner<span style="color: #333333;">.</span><span style="color: #0000cc;">setOnItemSelectedListener</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> mmItemSelectedListener<span style="color: #333333;">());</span>
mmSpinner<span style="color: #333333;">.</span><span style="color: #0000cc;">requestFocus</span><span style="color: #333333;">();</span>
String<span style="color: #333333;">[]</span> TZ <span style="color: #333333;">=</span> TimeZone<span style="color: #333333;">.</span><span style="color: #0000cc;">getAvailableIDs</span><span style="color: #333333;">();</span>
TZ<span style="color: #333333;">[</span><span style="color: #0000dd; font-weight: bold;">0</span><span style="color: #333333;">]</span> <span style="color: #333333;">=</span> <span style="background-color: #fff0f0;">"Select Time Zone"</span><span style="color: #333333;">;</span>
ArrayAdapter<span style="color: #333333;"><</span>String<span style="color: #333333;">></span> Timeadapter <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> ArrayAdapter<span style="color: #333333;"><</span>String<span style="color: #333333;">>(</span><span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">,</span>
android<span style="color: #333333;">.</span><span style="color: #0000cc;">R</span><span style="color: #333333;">.</span><span style="color: #0000cc;">layout</span><span style="color: #333333;">.</span><span style="color: #0000cc;">simple_spinner_item</span><span style="color: #333333;">,</span> TZ<span style="color: #333333;">);</span>
Timeadapter
<span style="color: #333333;">.</span><span style="color: #0000cc;">setDropDownViewResource</span><span style="color: #333333;">(</span>android<span style="color: #333333;">.</span><span style="color: #0000cc;">R</span><span style="color: #333333;">.</span><span style="color: #0000cc;">layout</span><span style="color: #333333;">.</span><span style="color: #0000cc;">simple_spinner_dropdown_item</span><span style="color: #333333;">);</span>
<span style="color: #888888;">// ArrayList<String> TZ1 = new ArrayList<String>();</span>
<span style="color: #888888;">// for (int i = 0; i < TZ.length; i++) {</span>
<span style="color: #888888;">// if (!(TZ1.contains(TimeZone.getTimeZone(TZ[i]).getDisplayName()))) {</span>
<span style="color: #888888;">// TZ1.add(TimeZone.getTimeZone(TZ[i]).getDisplayName());</span>
<span style="color: #888888;">// }</span>
<span style="color: #888888;">// }</span>
<span style="color: #888888;">// TZ1.add(0, "Select Time Zone");</span>
<span style="color: #888888;">// for (int i = 0; i < TZ1.size(); i++) {</span>
<span style="color: #888888;">// Timeadapter.add(TZ1.get(i));</span>
<span style="color: #888888;">// }</span>
spTimeZone<span style="color: #333333;">.</span><span style="color: #0000cc;">setAdapter</span><span style="color: #333333;">(</span>Timeadapter<span style="color: #333333;">);</span>
spTimeZone
<span style="color: #333333;">.</span><span style="color: #0000cc;">setOnItemSelectedListener</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> timeZoneItemSelectedListener<span style="color: #333333;">());</span>
spTimeZone<span style="color: #333333;">.</span><span style="color: #0000cc;">requestFocus</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">onClick</span><span style="color: #333333;">(</span>View v<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">switch</span> <span style="color: #333333;">(</span>v<span style="color: #333333;">.</span><span style="color: #0000cc;">getId</span><span style="color: #333333;">())</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">case</span> R<span style="color: #333333;">.</span><span style="color: #0000cc;">id</span><span style="color: #333333;">.</span><span style="color: #0000cc;">imgCal</span><span style="color: #333333;">:</span>
showDialog<span style="color: #333333;">(</span>DATE_DIALOG_ID<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">break</span><span style="color: #333333;">;</span>
<span style="color: #008800; font-weight: bold;">default</span><span style="color: #333333;">:</span>
<span style="color: #008800; font-weight: bold;">break</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// create date Dialog</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">protected</span> Dialog <span style="color: #0066bb; font-weight: bold;">onCreateDialog</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> id<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">switch</span> <span style="color: #333333;">(</span>id<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">case</span> <span style="color: #997700; font-weight: bold;">DATE_DIALOG_ID:</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">new</span> <span style="color: #0066bb; font-weight: bold;">DatePickerDialog</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">this</span><span style="color: #333333;">,</span> mDateSetListener<span style="color: #333333;">,</span> mYear<span style="color: #333333;">,</span> mMonth<span style="color: #333333;">,</span>
mDay<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">protected</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">onPrepareDialog</span><span style="color: #333333;">(</span><span style="color: #333399; font-weight: bold;">int</span> id<span style="color: #333333;">,</span> Dialog dialog<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">switch</span> <span style="color: #333333;">(</span>id<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">case</span> <span style="color: #997700; font-weight: bold;">DATE_DIALOG_ID:</span>
<span style="color: #333333;">((</span>DatePickerDialog<span style="color: #333333;">)</span> dialog<span style="color: #333333;">).</span><span style="color: #0000cc;">updateDate</span><span style="color: #333333;">(</span>mYear<span style="color: #333333;">,</span> mMonth<span style="color: #333333;">,</span> mDay<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">break</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">private</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">updateDisplay</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
mDateDisplay<span style="color: #333333;">.</span><span style="color: #0000cc;">setText</span><span style="color: #333333;">(</span><span style="color: #008800; font-weight: bold;">new</span> StringBuilder<span style="color: #333333;">()</span>
<span style="color: #888888;">// Month is 0 based so add 1</span>
<span style="color: #333333;">.</span><span style="color: #0000cc;">append</span><span style="color: #333333;">(</span>mYear<span style="color: #333333;">).</span><span style="color: #0000cc;">append</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"-"</span><span style="color: #333333;">).</span><span style="color: #0000cc;">append</span><span style="color: #333333;">(</span>mMonth <span style="color: #333333;">+</span> <span style="color: #0000dd; font-weight: bold;">1</span><span style="color: #333333;">).</span><span style="color: #0000cc;">append</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"-"</span><span style="color: #333333;">)</span>
<span style="color: #333333;">.</span><span style="color: #0000cc;">append</span><span style="color: #333333;">(</span>mDay<span style="color: #333333;">).</span><span style="color: #0000cc;">append</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">" "</span><span style="color: #333333;">));</span>
selectedDate <span style="color: #333333;">=</span> mDateDisplay<span style="color: #333333;">.</span><span style="color: #0000cc;">getText</span><span style="color: #333333;">().</span><span style="color: #0000cc;">toString</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">private</span> DatePickerDialog<span style="color: #333333;">.</span><span style="color: #0000cc;">OnDateSetListener</span> mDateSetListener <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> DatePickerDialog<span style="color: #333333;">.</span><span style="color: #0000cc;">OnDateSetListener</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">onDateSet</span><span style="color: #333333;">(</span>DatePicker view<span style="color: #333333;">,</span> <span style="color: #333399; font-weight: bold;">int</span> year<span style="color: #333333;">,</span> <span style="color: #333399; font-weight: bold;">int</span> monthOfYear<span style="color: #333333;">,</span>
<span style="color: #333399; font-weight: bold;">int</span> dayOfMonth<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
mYear <span style="color: #333333;">=</span> year<span style="color: #333333;">;</span>
mMonth <span style="color: #333333;">=</span> monthOfYear<span style="color: #333333;">;</span>
mDay <span style="color: #333333;">=</span> dayOfMonth<span style="color: #333333;">;</span>
updateDisplay<span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">};</span>
<span style="color: #888888;">// Hours Spinner</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">hhItemSelectedListener</span> <span style="color: #008800; font-weight: bold;">implements</span> OnItemSelectedListener <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">onItemSelected</span><span style="color: #333333;">(</span>AdapterView<span style="color: #333333;"><?></span> parent<span style="color: #333333;">,</span> View view<span style="color: #333333;">,</span> <span style="color: #333399; font-weight: bold;">int</span> pos<span style="color: #333333;">,</span>
<span style="color: #333399; font-weight: bold;">long</span> id<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
selectedHours <span style="color: #333333;">=</span> parent<span style="color: #333333;">.</span><span style="color: #0000cc;">getItemAtPosition</span><span style="color: #333333;">(</span>pos<span style="color: #333333;">).</span><span style="color: #0000cc;">toString</span><span style="color: #333333;">();</span>
<span style="color: #888888;">// showToast(selected);</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">onNothingSelected</span><span style="color: #333333;">(</span>AdapterView parent<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// minute spinner</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">mmItemSelectedListener</span> <span style="color: #008800; font-weight: bold;">implements</span> OnItemSelectedListener <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">onItemSelected</span><span style="color: #333333;">(</span>AdapterView<span style="color: #333333;"><?></span> parent<span style="color: #333333;">,</span> View view<span style="color: #333333;">,</span> <span style="color: #333399; font-weight: bold;">int</span> pos<span style="color: #333333;">,</span>
<span style="color: #333399; font-weight: bold;">long</span> id<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
selectedMinute <span style="color: #333333;">=</span> parent<span style="color: #333333;">.</span><span style="color: #0000cc;">getItemAtPosition</span><span style="color: #333333;">(</span>pos<span style="color: #333333;">).</span><span style="color: #0000cc;">toString</span><span style="color: #333333;">();</span>
<span style="color: #888888;">// showToast(selected);</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">onNothingSelected</span><span style="color: #333333;">(</span>AdapterView parent<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #888888;">// minute spinner</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #008800; font-weight: bold;">class</span> <span style="color: #bb0066; font-weight: bold;">timeZoneItemSelectedListener</span> <span style="color: #008800; font-weight: bold;">implements</span> OnItemSelectedListener <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">onItemSelected</span><span style="color: #333333;">(</span>AdapterView<span style="color: #333333;"><?></span> parent<span style="color: #333333;">,</span> View view<span style="color: #333333;">,</span> <span style="color: #333399; font-weight: bold;">int</span> pos<span style="color: #333333;">,</span>
<span style="color: #333399; font-weight: bold;">long</span> id<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
selectedZone <span style="color: #333333;">=</span> parent<span style="color: #333333;">.</span><span style="color: #0000cc;">getItemAtPosition</span><span style="color: #333333;">(</span>pos<span style="color: #333333;">).</span><span style="color: #0000cc;">toString</span><span style="color: #333333;">();</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>selectedHours<span style="color: #333333;">.</span><span style="color: #0000cc;">equalsIgnoreCase</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"hh"</span><span style="color: #333333;">)</span>
<span style="color: #333333;">||</span> selectedMinute<span style="color: #333333;">.</span><span style="color: #0000cc;">equalsIgnoreCase</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"mm"</span><span style="color: #333333;">)</span>
<span style="color: #333333;">||</span> selectedZone<span style="color: #333333;">.</span><span style="color: #0000cc;">equalsIgnoreCase</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Select Time Zone"</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Please Select time and date and time zone"</span><span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
String dateTime <span style="color: #333333;">=</span> selectedDate <span style="color: #333333;">+</span> selectedHours <span style="color: #333333;">+</span> <span style="background-color: #fff0f0;">":"</span>
<span style="color: #333333;">+</span> selectedMinute<span style="color: #333333;">;</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"old Date time - "</span> <span style="color: #333333;">+</span> dateTime<span style="color: #333333;">);</span>
String startTime <span style="color: #333333;">=</span> dateTime<span style="color: #333333;">;</span>
SimpleDateFormat dateFormat <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> SimpleDateFormat<span style="color: #333333;">(</span>
<span style="background-color: #fff0f0;">"yyyy-MM-dd HH:mm"</span><span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
date1 <span style="color: #333333;">=</span> dateFormat<span style="color: #333333;">.</span><span style="color: #0000cc;">parse</span><span style="color: #333333;">(</span>startTime<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>ParseException e<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #888888;">// TODO Auto-generated catch block</span>
e<span style="color: #333333;">.</span><span style="color: #0000cc;">printStackTrace</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Formatted Date time - "</span> <span style="color: #333333;">+</span> date1<span style="color: #333333;">);</span>
date1 <span style="color: #333333;">=</span> GetUTCdatetimeAsDate<span style="color: #333333;">();</span>
<span style="color: #888888;">// String utcDate = GetUTCdatetimeAsString();</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"UTC DATE => "</span> <span style="color: #333333;">+</span> date1<span style="color: #333333;">);</span>
etUtc<span style="color: #333333;">.</span><span style="color: #0000cc;">setText</span><span style="color: #333333;">(</span>date1<span style="color: #333333;">.</span><span style="color: #0000cc;">toString</span><span style="color: #333333;">());</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">onNothingSelected</span><span style="color: #333333;">(</span>AdapterView parent<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #333333;">}</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> Date <span style="color: #0066bb; font-weight: bold;">GetUTCdatetimeAsDate</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #888888;">// note: doesn't check for null</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #0066bb; font-weight: bold;">StringDateToDate</span><span style="color: #333333;">(</span>GetUTCdatetimeAsString<span style="color: #333333;">());</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> String <span style="color: #0066bb; font-weight: bold;">GetUTCdatetimeAsString</span><span style="color: #333333;">()</span> <span style="color: #333333;">{</span>
<span style="color: #008800; font-weight: bold;">final</span> SimpleDateFormat sdf <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> SimpleDateFormat<span style="color: #333333;">(</span>DATEFORMAT<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">if</span> <span style="color: #333333;">(</span>selectedZone<span style="color: #333333;">.</span><span style="color: #0000cc;">equalsIgnoreCase</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Select Time Zone"</span><span style="color: #333333;">))</span> <span style="color: #333333;">{</span>
System<span style="color: #333333;">.</span><span style="color: #0000cc;">out</span><span style="color: #333333;">.</span><span style="color: #0000cc;">println</span><span style="color: #333333;">(</span><span style="background-color: #fff0f0;">"Selecte Time Zone Please"</span><span style="color: #333333;">);</span>
Toast<span style="color: #333333;">.</span><span style="color: #0000cc;">makeText</span><span style="color: #333333;">(</span>MainActivity<span style="color: #333333;">.</span><span style="color: #0000cc;">this</span><span style="color: #333333;">,</span> <span style="background-color: #fff0f0;">"Selecte Time Zone Please"</span><span style="color: #333333;">,</span> Toast<span style="color: #333333;">.</span><span style="color: #0000cc;">LENGTH_LONG</span><span style="color: #333333;">).</span><span style="color: #0000cc;">show</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">else</span> <span style="color: #333333;">{</span>
sdf<span style="color: #333333;">.</span><span style="color: #0000cc;">setTimeZone</span><span style="color: #333333;">(</span>TimeZone<span style="color: #333333;">.</span><span style="color: #0000cc;">getTimeZone</span><span style="color: #333333;">(</span>selectedZone<span style="color: #333333;">));</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">final</span> String utcTime <span style="color: #333333;">=</span> sdf<span style="color: #333333;">.</span><span style="color: #0000cc;">format</span><span style="color: #333333;">(</span>date1<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">return</span> utcTime<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">public</span> Date <span style="color: #0066bb; font-weight: bold;">StringDateToDate</span><span style="color: #333333;">(</span>String StrDate<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
Date dateToReturn <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">null</span><span style="color: #333333;">;</span>
SimpleDateFormat dateFormat <span style="color: #333333;">=</span> <span style="color: #008800; font-weight: bold;">new</span> SimpleDateFormat<span style="color: #333333;">(</span>DATEFORMAT<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">try</span> <span style="color: #333333;">{</span>
dateToReturn <span style="color: #333333;">=</span> <span style="color: #333333;">(</span>Date<span style="color: #333333;">)</span> dateFormat<span style="color: #333333;">.</span><span style="color: #0000cc;">parse</span><span style="color: #333333;">(</span>StrDate<span style="color: #333333;">);</span>
<span style="color: #333333;">}</span> <span style="color: #008800; font-weight: bold;">catch</span> <span style="color: #333333;">(</span>ParseException e<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
e<span style="color: #333333;">.</span><span style="color: #0000cc;">printStackTrace</span><span style="color: #333333;">();</span>
<span style="color: #333333;">}</span>
<span style="color: #008800; font-weight: bold;">return</span> dateToReturn<span style="color: #333333;">;</span>
<span style="color: #333333;">}</span>
<span style="color: #555555; font-weight: bold;">@Override</span>
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #333399; font-weight: bold;">boolean</span> <span style="color: #0066bb; font-weight: bold;">onCreateOptionsMenu</span><span style="color: #333333;">(</span>Menu menu<span style="color: #333333;">)</span> <span style="color: #333333;">{</span>
<span style="color: #888888;">// Inflate the menu; this adds items to the action bar if it is present.</span>
getMenuInflater<span style="color: #333333;">().</span><span style="color: #0000cc;">inflate</span><span style="color: #333333;">(</span>R<span style="color: #333333;">.</span><span style="color: #0000cc;">menu</span><span style="color: #333333;">.</span><span style="color: #0000cc;">main</span><span style="color: #333333;">,</span> menu<span style="color: #333333;">);</span>
<span style="color: #008800; font-weight: bold;">return</span> <span style="color: #008800; font-weight: bold;">true</span><span style="color: #333333;">;</span>
<span style="color: #333333;">}</span></pre>
</td></tr>
</tbody></table>
</div>
In Above Code Line number 69 is important<br />
- Timezone : Most applications will use getDefault() which returns a TimeZone based on the time zone where the program is running.<br />
- TimeZone.getAvailableIDs Returns the system's installed time zone IDs. Any of these IDs can be passed to getTimeZone(String) to lookup the corresponding time zone instance.
<br />
<br />
If you wish to download complete source code. you can download from below link<br />
<a href="http://www.4shared.com/zip/MmBVzKEp/UTC.html" target="_blank">UTC Calculator</a><br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/06071431205366911491noreply@blogger.com1tag:blogger.com,1999:blog-3717595520751951033.post-21629432339770060252012-09-23T04:49:00.000-07:002012-09-23T04:49:25.090-07:00Android Chat Application<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: inherit;">In Today's Smart Phone Life Mobile Chat is very popular and In this</span> Article I will explain about android chat application.Not a whole scenario but some part of the chatting application like how we can add a emoticon in to your edittext and displayed in to the screen.<br />
<div>
<br /></div>
<div>
end of the document i post a download full source code.Here Below some Java file and screen shots is available<br />
<u><span style="color: #cc0000;">MainActivity.java</span></u></div>
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; background: white; border-width: .1em .1em .1em .8em; border: solid gray; color: black; overflow: auto; padding: .2em .6em; width: auto;">
<table><tbody>
<tr><td><pre style="line-height: 125%; margin: 0;"> 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95</pre>
</td><td><pre style="line-height: 125%; margin: 0;"><span style="color: navy; font-weight: bold;">package</span> com.<span style="color: red;">example</span>.<span style="color: red;">mysmiley</span>;
<span style="color: navy; font-weight: bold;">import</span> android.app.Activity;
<span style="color: navy; font-weight: bold;">import</span> android.content.Intent;
<span style="color: navy; font-weight: bold;">import</span> android.content.SharedPreferences;
<span style="color: navy; font-weight: bold;">import</span> android.graphics.drawable.Drawable;
<span style="color: navy; font-weight: bold;">import</span> android.os.Bundle;
<span style="color: navy; font-weight: bold;">import</span> android.text.Editable;
<span style="color: navy; font-weight: bold;">import</span> android.text.Html;
<span style="color: navy; font-weight: bold;">import</span> android.text.Html.ImageGetter;
<span style="color: navy; font-weight: bold;">import</span> android.text.Selection;
<span style="color: navy; font-weight: bold;">import</span> android.view.View;
<span style="color: navy; font-weight: bold;">import</span> android.view.View.OnClickListener;
<span style="color: navy; font-weight: bold;">import</span> android.widget.Button;
<span style="color: navy; font-weight: bold;">import</span> android.widget.EditText;
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">class</span> MainActivity <span style="color: navy; font-weight: bold;">extends</span> Activity <span style="color: navy; font-weight: bold;">implements</span> OnClickListener {
EditText display, writeboard;
Button submit, select,clear;
@Override
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">void</span> onCreate(Bundle savedInstanceState) {
<span style="color: navy; font-weight: bold;">super</span>.<span style="color: red;">onCreate</span>(savedInstanceState);
setContentView(R.<span style="color: red;">layout</span>.<span style="color: red;">activity_main</span>);
initUiElement();
submit.<span style="color: red;">setOnClickListener</span>(<span style="color: navy; font-weight: bold;">this</span>);
select.<span style="color: red;">setOnClickListener</span>(<span style="color: navy; font-weight: bold;">this</span>);
clear.<span style="color: red;">setOnClickListener</span>(<span style="color: navy; font-weight: bold;">this</span>);
}
<span style="color: navy; font-weight: bold;">private</span> <span style="color: navy; font-weight: bold;">void</span> initUiElement() {
display = (EditText) findViewById(R.<span style="color: red;">id</span>.<span style="color: red;">display</span>);
writeboard = (EditText) findViewById(R.<span style="color: red;">id</span>.<span style="color: red;">writeboard</span>);
submit = (Button) findViewById(R.<span style="color: red;">id</span>.<span style="color: red;">btnsubmit</span>);
select = (Button) findViewById(R.<span style="color: red;">id</span>.<span style="color: red;">btnselect</span>);
clear = (Button)findViewById(R.<span style="color: red;">id</span>.<span style="color: red;">btnclear</span>);
}
CharSequence cs;
CustomEmojis emojis;
<span style="color: navy; font-weight: bold;">int</span> index;
@Override
<span style="color: navy; font-weight: bold;">protected</span> <span style="color: navy; font-weight: bold;">void</span> onRestart() {
<span style="color: navy; font-weight: bold;">super</span>.<span style="color: red;">onRestart</span>();
emojis = <span style="color: navy; font-weight: bold;">new</span> CustomEmojis(<span style="color: navy; font-weight: bold;">this</span>);
SharedPreferences preferences = <span style="color: navy; font-weight: bold;">this</span>.<span style="color: red;">getSharedPreferences</span>(<span style="color: blue;">"pref"</span>,
<span style="color: navy; font-weight: bold;">this</span>.<span style="color: red;">MODE_WORLD_READABLE</span>);
index = preferences.<span style="color: red;">getInt</span>(<span style="color: blue;">"smiley"</span>, <span style="color: blue;">0</span>);
System.<span style="color: red;">out</span>.<span style="color: red;">println</span>(<span style="color: blue;">"smiley index is---> "</span> + index);
ImageGetter imageGetter = <span style="color: navy; font-weight: bold;">new</span> ImageGetter() {
@Override
<span style="color: navy; font-weight: bold;">public</span> Drawable getDrawable(String source) {
Drawable d = getResources().<span style="color: red;">getDrawable</span>(emojis.<span style="color: red;">images</span>[index]);
d.<span style="color: red;">setBounds</span>(<span style="color: blue;">0</span>, <span style="color: blue;">0</span>, d.<span style="color: red;">getIntrinsicWidth</span>(), d.<span style="color: red;">getIntrinsicHeight</span>());
<span style="color: navy; font-weight: bold;">return</span> d;
}
};
cs = Html.<span style="color: red;">fromHtml</span>(
<span style="color: blue;">"<img src ='"</span>
+ getResources().<span style="color: red;">getDrawable</span>(emojis.<span style="color: red;">images</span>[index])
+ <span style="color: blue;">"'/>"</span>, imageGetter, <span style="color: navy; font-weight: bold;">null</span>);
writeboard.<span style="color: red;">setText</span>(cs);
<span style="color: navy; font-weight: bold;">int</span> position = writeboard.<span style="color: red;">length</span>();
Editable editable = writeboard.<span style="color: red;">getText</span>();
Selection.<span style="color: red;">setSelection</span>(editable, position);
}
@Override
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">void</span> onClick(View v) {
<span style="color: navy; font-weight: bold;">switch</span> (v.<span style="color: red;">getId</span>()) {
<span style="color: navy; font-weight: bold;">case</span> R.<span style="color: red;">id</span>.<span style="color: red;">btnsubmit</span>:
display.<span style="color: red;">setText</span>(display.<span style="color: red;">getText</span>().<span style="color: red;">append</span>(writeboard.<span style="color: red;">getText</span>()));
writeboard.<span style="color: red;">setText</span>(<span style="color: blue;">""</span>);
<span style="color: navy; font-weight: bold;">break</span>;
<span style="color: navy; font-weight: bold;">case</span> R.<span style="color: red;">id</span>.<span style="color: red;">btnselect</span>:
Intent i = <span style="color: navy; font-weight: bold;">new</span> Intent(MainActivity.<span style="color: red;">this</span>, EmojiSelection.<span style="color: red;">class</span>);
startActivity(i);
<span style="color: navy; font-weight: bold;">break</span>;
<span style="color: navy; font-weight: bold;">case</span> R.<span style="color: red;">id</span>.<span style="color: red;">btnclear</span>:
display.<span style="color: red;">setText</span>(<span style="color: blue;">""</span>);
<span style="color: navy; font-weight: bold;">break</span>;
<span style="color: navy; font-weight: bold;">default</span>:
<span style="color: navy; font-weight: bold;">break</span>;
}
}
}
</pre>
</td></tr>
</tbody></table>
</div>
<div>
<br />
After main file creation you need to create another activity EmojiSelection Activity. in this activity you show that how the emoji will selected using shared preference.<br />
<br />
<u><span style="color: #cc0000;">EmojiSelection.java</span></u><br />
<u><span style="color: #cc0000;"><br /></span></u>
<u><span style="color: #cc0000;"><br /></span></u>
<u><span style="color: #cc0000;"><br /></span></u>
<u><span style="color: #cc0000;"><br /></span></u>
</div>
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; background: white; border-width: .1em .1em .1em .8em; border: solid gray; color: black; overflow: auto; padding: .2em .6em; width: auto;">
<table><tbody>
<tr><td><pre style="line-height: 125%; margin: 0;"> 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55</pre>
</td><td><pre style="line-height: 125%; margin: 0;"><span style="color: navy; font-weight: bold;">package</span> com.<span style="color: red;">example</span>.<span style="color: red;">mysmiley</span>;
<span style="color: navy; font-weight: bold;">import</span> android.app.Activity;
<span style="color: navy; font-weight: bold;">import</span> android.content.SharedPreferences;
<span style="color: navy; font-weight: bold;">import</span> android.os.Bundle;
<span style="color: navy; font-weight: bold;">import</span> android.util.Log;
<span style="color: navy; font-weight: bold;">import</span> android.view.View;
<span style="color: navy; font-weight: bold;">import</span> android.widget.AdapterView;
<span style="color: navy; font-weight: bold;">import</span> android.widget.AdapterView.OnItemClickListener;
<span style="color: navy; font-weight: bold;">import</span> android.widget.GridView;
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">class</span> EmojiSelection <span style="color: navy; font-weight: bold;">extends</span> Activity {
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">static</span> <span style="color: navy; font-weight: bold;">final</span> String TAG = <span style="color: blue;">"EmojiSelection"</span>;
GridView gridView;
CustomEmojis customEmojis;
@Override
<span style="color: navy; font-weight: bold;">protected</span> <span style="color: navy; font-weight: bold;">void</span> onCreate(Bundle savedInstanceState) {
<span style="color: navy; font-weight: bold;">super</span>.<span style="color: red;">onCreate</span>(savedInstanceState);
setContentView(R.<span style="color: red;">layout</span>.<span style="color: red;">emojis</span>);
initUIElement();
customEmojis = <span style="color: navy; font-weight: bold;">new</span> CustomEmojis(<span style="color: navy; font-weight: bold;">this</span>);
gridView.<span style="color: red;">setAdapter</span>(customEmojis);
gridView.<span style="color: red;">setOnItemClickListener</span>(<span style="color: navy; font-weight: bold;">new</span> OnItemClickListener() {
@Override
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">void</span> onItemClick(AdapterView<?> arg0, View arg1,
<span style="color: navy; font-weight: bold;">int</span> position, <span style="color: navy; font-weight: bold;">long</span> arg3) {
Log.<span style="color: red;">i</span>(TAG, <span style="color: blue;">"U are in OnItemSelected"</span>);
SharedPreferences preferences = EmojiSelection.<span style="color: red;">this</span>
.<span style="color: red;">getSharedPreferences</span>(<span style="color: blue;">"pref"</span>, MODE_WORLD_READABLE);
SharedPreferences.<span style="color: red;">Editor</span> editor = preferences.<span style="color: red;">edit</span>();
editor.<span style="color: red;">putInt</span>(<span style="color: blue;">"smiley"</span>, position);
System.<span style="color: red;">out</span>.<span style="color: red;">println</span>(<span style="color: blue;">"Selected emojis ---> "</span> + position);
<span style="color: #008800; font-style: italic;">// dont forgot to commit preference</span>
editor.<span style="color: red;">commit</span>();
finish();
}
});
}
<span style="color: navy; font-weight: bold;">private</span> <span style="color: navy; font-weight: bold;">void</span> initUIElement() {
gridView = (GridView) findViewById(R.<span style="color: red;">id</span>.<span style="color: red;">gridview1</span>);
}
}
</pre>
</td></tr>
</tbody></table>
</div>
<div>
<br />
in my example i am create custom gridview class for the displaying the emojis. In below code you can see.<br />
<u><span style="color: #cc0000;">CustomEmojis.java</span></u><br />
<br />
<br /></div>
<!-- HTML generated using hilite.me --><br />
<div style="background: #ffffff; background: white; border-width: .1em .1em .1em .8em; border: solid gray; color: black; overflow: auto; padding: .2em .6em; width: auto;">
<table><tbody>
<tr><td><pre style="line-height: 125%; margin: 0;"> 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68</pre>
</td><td><pre style="line-height: 125%; margin: 0;"><span style="color: navy; font-weight: bold;">package</span> com.<span style="color: red;">example</span>.<span style="color: red;">mysmiley</span>;
<span style="color: navy; font-weight: bold;">import</span> android.app.Activity;
<span style="color: navy; font-weight: bold;">import</span> android.content.Context;
<span style="color: navy; font-weight: bold;">import</span> android.view.LayoutInflater;
<span style="color: navy; font-weight: bold;">import</span> android.view.View;
<span style="color: navy; font-weight: bold;">import</span> android.view.ViewGroup;
<span style="color: navy; font-weight: bold;">import</span> android.widget.BaseAdapter;
<span style="color: navy; font-weight: bold;">import</span> android.widget.ImageView;
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">class</span> CustomEmojis <span style="color: navy; font-weight: bold;">extends</span> BaseAdapter {
<span style="color: navy; font-weight: bold;">private</span> Activity activity;
<span style="color: navy; font-weight: bold;">private</span> <span style="color: navy; font-weight: bold;">static</span> LayoutInflater inflater = <span style="color: navy; font-weight: bold;">null</span>;
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">final</span> <span style="color: navy; font-weight: bold;">int</span>[] images = <span style="color: navy; font-weight: bold;">new</span> <span style="color: navy; font-weight: bold;">int</span>[] { R.<span style="color: red;">drawable</span>.<span style="color: red;">a</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">b</span>,
R.<span style="color: red;">drawable</span>.<span style="color: red;">c</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">d</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">e</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">f</span>,
R.<span style="color: red;">drawable</span>.<span style="color: red;">g</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">h</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">j</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">k</span>,
R.<span style="color: red;">drawable</span>.<span style="color: red;">l</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">m</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">n</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">o</span>,
R.<span style="color: red;">drawable</span>.<span style="color: red;">p</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">q</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">r</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">s</span>,
R.<span style="color: red;">drawable</span>.<span style="color: red;">t</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">u</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">v</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">w</span>,
R.<span style="color: red;">drawable</span>.<span style="color: red;">x</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">y</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">z</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">aa</span>,
R.<span style="color: red;">drawable</span>.<span style="color: red;">bb</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">cc</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">dd</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">ee</span>,
R.<span style="color: red;">drawable</span>.<span style="color: red;">ff</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">gg</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">hh</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">ii</span>,
R.<span style="color: red;">drawable</span>.<span style="color: red;">jj</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">kk</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">ll</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">mm</span>,
R.<span style="color: red;">drawable</span>.<span style="color: red;">nn</span>, R.<span style="color: red;">drawable</span>.<span style="color: red;">oo</span>, };
<span style="color: navy; font-weight: bold;">public</span> CustomEmojis(Activity act) {
activity = act;
inflater = (LayoutInflater) activity
.<span style="color: red;">getSystemService</span>(Context.<span style="color: red;">LAYOUT_INFLATER_SERVICE</span>);
}
@Override
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">int</span> getCount() {
<span style="color: navy; font-weight: bold;">return</span> images.<span style="color: red;">length</span>;
}
@Override
<span style="color: navy; font-weight: bold;">public</span> Object getItem(<span style="color: navy; font-weight: bold;">int</span> position) {
<span style="color: navy; font-weight: bold;">return</span> position;
}
@Override
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">long</span> getItemId(<span style="color: navy; font-weight: bold;">int</span> position) {
<span style="color: navy; font-weight: bold;">return</span> position;
}
@Override
<span style="color: navy; font-weight: bold;">public</span> View getView(<span style="color: navy; font-weight: bold;">int</span> position, View convertView, ViewGroup parent) {
ViewHolder holder;
<span style="color: navy; font-weight: bold;">if</span> (convertView == <span style="color: navy; font-weight: bold;">null</span>) {
holder = <span style="color: navy; font-weight: bold;">new</span> ViewHolder();
convertView = inflater.<span style="color: red;">inflate</span>(R.<span style="color: red;">layout</span>.<span style="color: red;">grid_row</span>, <span style="color: navy; font-weight: bold;">null</span>);
holder.<span style="color: red;">imageView</span> = (ImageView) convertView
.<span style="color: red;">findViewById</span>(R.<span style="color: red;">id</span>.<span style="color: red;">imageView1</span>);
convertView.<span style="color: red;">setTag</span>(holder);
} <span style="color: navy; font-weight: bold;">else</span> {
holder = (ViewHolder) convertView.<span style="color: red;">getTag</span>();
}
holder.<span style="color: red;">imageView</span>.<span style="color: red;">setImageResource</span>(images[position]);
<span style="color: navy; font-weight: bold;">return</span> convertView;
}
<span style="color: navy; font-weight: bold;">public</span> <span style="color: navy; font-weight: bold;">static</span> <span style="color: navy; font-weight: bold;">class</span> ViewHolder {
<span style="color: navy; font-weight: bold;">public</span> ImageView imageView;
}
}
</pre>
</td></tr>
</tbody></table>
</div>
<div>
<br />
above i post a 3 useful file for project.now its up to YOU how you can made a chat application in android Now after completion of the project you can see the below screens in you project<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRLwUKUYZ26IOi8BKlOGYvrIRpcY6TeLetLK6htRiyHG8n-rUG_vWeqxHlK7ZT5mH8xhkrCjJRRK7VN_LeMkdwQGKa4ljWQQ7rGzqz6maV1j4Mhkq73RfoIwSIdoIueb2JQ_7KKFKruiep/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRLwUKUYZ26IOi8BKlOGYvrIRpcY6TeLetLK6htRiyHG8n-rUG_vWeqxHlK7ZT5mH8xhkrCjJRRK7VN_LeMkdwQGKa4ljWQQ7rGzqz6maV1j4Mhkq73RfoIwSIdoIueb2JQ_7KKFKruiep/s320/3.png" width="213" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVYxCV03dxtAQVMrukUas7c7NdUHvkdmu0kL6rxEI7Kiwu3ALJVIqecKpJ8xza4MsftqWMmhWHv700O-zy-7icjELQg9tohEyQo6L5Ey5GAh470lm6fmZio7wdrv8Y9BfIAV4p4cy7ghFx/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVYxCV03dxtAQVMrukUas7c7NdUHvkdmu0kL6rxEI7Kiwu3ALJVIqecKpJ8xza4MsftqWMmhWHv700O-zy-7icjELQg9tohEyQo6L5Ey5GAh470lm6fmZio7wdrv8Y9BfIAV4p4cy7ghFx/s320/2.png" width="213" /></a></div>
you can download a full source code <a href="http://www.4shared.com/zip/2bI3D1F6/MySmiley.html" rel="nofollow" target="_blank">here</a> </div>
</div>
Anonymoushttp://www.blogger.com/profile/06071431205366911491noreply@blogger.com10Pedak Rd, Arya Nagar, Rajkot, Gujarat, India22.3055572 70.824152822.3018847 70.819217299999991 22.3092297 70.8290883tag:blogger.com,1999:blog-3717595520751951033.post-67077599940467854122012-09-17T00:00:00.000-07:002012-09-17T02:07:53.690-07:00Exapand - Collapse Android TextView.<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Arial, Helvetica, sans-serif;">Hello,</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">Here I want to share some knowledge about android textview. Android Textview is a very Useful element in your application.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;">If you want to make functionality like expand - collapse of textview it is easy after end of this article you can make this functionality.</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">I guess,you have a basic knowledge of Android technology. Than you can easily grasp this article</span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span>
<span style="font-family: Arial, Helvetica, sans-serif;">e.g. If you want to expand or collapse your textview like in below is image of Play store app.</span><br />
<span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZdz731VItbsV7W7C-z0dyqfepo_0260UC4PIlKasipWtv4_J6ACUCsMFbxq1XEAQbALo6s6UBzaRm8ll851eNZd_cwkhHRxxso6Uvc_8ZlYVUgNceyBNlto1lqpYZmV9Lwrqzj0WLEtEC/s1600/0hqno.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZdz731VItbsV7W7C-z0dyqfepo_0260UC4PIlKasipWtv4_J6ACUCsMFbxq1XEAQbALo6s6UBzaRm8ll851eNZd_cwkhHRxxso6Uvc_8ZlYVUgNceyBNlto1lqpYZmV9Lwrqzj0WLEtEC/s320/0hqno.jpg" width="192" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Here I am only describe that how more/less button functionality are work. </div>
<div class="separator" style="clear: both; text-align: left;">
first of all in your activity_main.xml file paste below code.</div>
<div class="separator" style="clear: both; text-align: left;">
<b><span style="color: red;">activity_main.xml</span></b>
</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both;">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"</div>
<div class="separator" style="clear: both;">
xmlns:tools="http://schemas.android.com/tools"</div>
<div class="separator" style="clear: both;">
android:layout_width="match_parent"</div>
<div class="separator" style="clear: both;">
android:layout_height="match_parent" ></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<RelativeLayout</div>
<div class="separator" style="clear: both;">
android:layout_width="match_parent"</div>
<div class="separator" style="clear: both;">
android:layout_height="wrap_content" ></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<TextView</div>
<div class="separator" style="clear: both;">
android:id="@+id/description_text"</div>
<div class="separator" style="clear: both;">
android:layout_width="match_parent"</div>
<div class="separator" style="clear: both;">
android:layout_height="wrap_content"</div>
<div class="separator" style="clear: both;">
android:maxLines="5"</div>
<div class="separator" style="clear: both;">
android:text="@string/desc_content" /></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<ImageButton</div>
<div class="separator" style="clear: both;">
android:id="@+id/show"</div>
<div class="separator" style="clear: both;">
android:layout_width="wrap_content"</div>
<div class="separator" style="clear: both;">
android:layout_height="wrap_content"</div>
<div class="separator" style="clear: both;">
android:layout_alignParentRight="true"</div>
<div class="separator" style="clear: both;">
android:layout_below="@+id/description_text"</div>
<div class="separator" style="clear: both;">
android:background="@drawable/arrow_down"</div>
<div class="separator" style="clear: both;">
android:clickable="true" /></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<View</div>
<div class="separator" style="clear: both;">
android:id="@+id/view1"</div>
<div class="separator" style="clear: both;">
android:layout_width="wrap_content"</div>
<div class="separator" style="clear: both;">
android:layout_height="2dp"</div>
<div class="separator" style="clear: both;">
android:layout_below="@+id/description_text"</div>
<div class="separator" style="clear: both;">
android:layout_marginTop="5dp"</div>
<div class="separator" style="clear: both;">
android:layout_toLeftOf="@+id/show"</div>
<div class="separator" style="clear: both;">
android:background="#000" /></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<ImageButton</div>
<div class="separator" style="clear: both;">
android:id="@+id/hide"</div>
<div class="separator" style="clear: both;">
android:layout_width="wrap_content"</div>
<div class="separator" style="clear: both;">
android:layout_height="wrap_content"</div>
<div class="separator" style="clear: both;">
android:layout_alignParentRight="true"</div>
<div class="separator" style="clear: both;">
android:layout_below="@+id/description_text"</div>
<div class="separator" style="clear: both;">
android:background="@drawable/arrow_up"</div>
<div class="separator" style="clear: both;">
android:clickable="true"</div>
<div class="separator" style="clear: both;">
android:visibility="invisible" /></div>
<div class="separator" style="clear: both;">
</RelativeLayout></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
</ScrollView></div>
<br />
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
now open your main java file and paste below code</div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: red;">MainActivity.java</span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="separator" style="clear: both;">
package com.example.expand.textview;</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
import android.app.Activity;</div>
<div class="separator" style="clear: both;">
import android.os.Bundle;</div>
<div class="separator" style="clear: both;">
import android.view.View;</div>
<div class="separator" style="clear: both;">
import android.view.View.OnClickListener;</div>
<div class="separator" style="clear: both;">
import android.widget.ImageButton;</div>
<div class="separator" style="clear: both;">
import android.widget.TextView;</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
public class MainActivity extends Activity {</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>TextView descText;</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>ImageButton show, hide;</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>@Override</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void onCreate(Bundle savedInstanceState) {</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>super.onCreate(savedInstanceState);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>setContentView(R.layout.activity_main);</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>descText = (TextView) findViewById(R.id.description_text);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>show = (ImageButton) findViewById(R.id.show);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>show.setOnClickListener(new OnClickListener() {</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>@Override</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void onClick(View v) {</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("Show button");</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>show.setVisibility(View.INVISIBLE);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>hide.setVisibility(View.VISIBLE);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>descText.setMaxLines(Integer.MAX_VALUE);</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>});</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>hide = (ImageButton) findViewById(R.id.hide);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>hide.setOnClickListener(new OnClickListener() {</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>@Override</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void onClick(View v) {</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("Hide button");</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>hide.setVisibility(View.INVISIBLE);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>show.setVisibility(View.VISIBLE);</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>descText.setMaxLines(5);</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>});</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
}</div>
<div>
<br /></div>
<div>
and finally change your string.xml file</div>
<div>
<b><span style="color: red;">string.xml</span></b></div>
<div>
<b><span style="color: red;"><br /></span></b></div>
<div>
<div>
<resources></div>
<div>
<br /></div>
<div>
<string name="app_name">Expand TextView</string></div>
<div>
<string name="hello_world">Hello world!</string></div>
<div>
<string name="menu_settings">Settings</string></div>
<div>
<string name="title_activity_main">MainActivity</string></div>
<div>
<string name="desc_content"><span class="Apple-tab-span" style="white-space: pre;"> </span> Android powers hundreds of millions of mobile devices in more than 190 countries around the world. It\'s the largest installed base of any mobile platform and growing fast—every day another million users power up their Android devices for the first time and start looking for apps, games, and other digital content.</div>
<div>
<br /></div>
<div>
Android gives you a world-class platform for creating apps and games for Android users everywhere, as well as an open marketplace for distributing to them instantly.</div>
<div>
</string></div>
<div>
<br /></div>
<div>
</resources></div>
<div style="font-weight: bold;">
<br /></div>
<div>
and run your Project It will give you below output.</div>
</div>
<div>
<br /></div>
<a name='more'></a><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEir73zJxaKCcVLSety6Gga53A-DI2hcF_Xa3i71TUIVHdGCP5RnSser7kcaqQWPjKcDz7IG_WKelbiJoqOXYBczJHVHtpu_jtultBXlx473HmBJEVrYR6wPUgSPKmu3_sa7nORY4fssTwsQ/s1600/device-2012-09-17-105529.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEir73zJxaKCcVLSety6Gga53A-DI2hcF_Xa3i71TUIVHdGCP5RnSser7kcaqQWPjKcDz7IG_WKelbiJoqOXYBczJHVHtpu_jtultBXlx473HmBJEVrYR6wPUgSPKmu3_sa7nORY4fssTwsQ/s320/device-2012-09-17-105529.png" width="213" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
After Clicking on the arrow button you will see the below screen in your application. it will expand your textview to maximum of height.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibLMzmvMauSJZZFs7szkDeJeT-wHey1by_ZO_QqagAaMhstqNjZS6sn60CDo39jE9NHbkULk4Qpda80HXYklXqV8oUgABD_7DCUCln4_HimxsuYlDxZ-j-Hhm2ietjW6dLAowwprG0o2k9/s1600/device-2012-09-17-105548.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibLMzmvMauSJZZFs7szkDeJeT-wHey1by_ZO_QqagAaMhstqNjZS6sn60CDo39jE9NHbkULk4Qpda80HXYklXqV8oUgABD_7DCUCln4_HimxsuYlDxZ-j-Hhm2ietjW6dLAowwprG0o2k9/s320/device-2012-09-17-105548.png" width="213" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
I Also added image of arrow button. from below you can download</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDGhRW5m4LlgcFt8EkktPX_J7JwQcREuorjm1Q5Ohdk98u84nQAMyKpXMh_AO7s6BPHw-HqLcFqHbWtCGqdTO9moD3sE4t9xilFdx-dItfJcO49Yc0Cf_PUof_vZbGzCjQ5IXqrTnDHWj5/s1600/1345618612_arrow-down.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDGhRW5m4LlgcFt8EkktPX_J7JwQcREuorjm1Q5Ohdk98u84nQAMyKpXMh_AO7s6BPHw-HqLcFqHbWtCGqdTO9moD3sE4t9xilFdx-dItfJcO49Yc0Cf_PUof_vZbGzCjQ5IXqrTnDHWj5/s1600/1345618612_arrow-down.png" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCOjNO-YvNv3WLSeQNNu3wto43F5WvzL-MglfiDDRMh2Q9o-tjh6geb6hxF0AhtjyFCBo20G7pL4PyzMGqrOCA2hSgubxF5giVLfNLqLujSTBFif5QplDv0-FKS9XECiMpBbHRTI3ndvbD/s1600/1345618830_arrow-up.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCOjNO-YvNv3WLSeQNNu3wto43F5WvzL-MglfiDDRMh2Q9o-tjh6geb6hxF0AhtjyFCBo20G7pL4PyzMGqrOCA2hSgubxF5giVLfNLqLujSTBFif5QplDv0-FKS9XECiMpBbHRTI3ndvbD/s1600/1345618830_arrow-up.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div>
<b><span style="color: red;"><br /></span></b></div>
<div>
<b><span style="color: red;"><br /></span></b></div>
<br />
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"><br /></span></div>
Anonymoushttp://www.blogger.com/profile/06071431205366911491noreply@blogger.com8State Highway 25, Sadar, Rajkot, Gujarat, India22.3038945 70.802159922.1863645 70.64423140000001 22.421424499999997 70.9600884