Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Power Lifting Lever Belt
SkullVamp
Updated:
Jun 13, 2026
Ad icon
port.lk Domain for sale
Lankan-Tech
Updated:
Jun 13, 2026
Colombo
Kaduwela - Two Storey House for Sale
dilrasan
Updated:
Jun 11, 2026
Ad icon
Wechat qr verification
Pawan2005
Updated:
Jun 11, 2026
🚀 GOOGLE AI PRO 18 MONTHS ACTIVATION 🚀
sayuru bandara
Updated:
Jun 10, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
Android Programming 2
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="KRipTER" data-source="post: 19029631" data-attributes="member: 548168"><p><span style="font-size: 12px"><span style="font-size: 12px"><span style="font-size: 12px">ඔන්න android නුලේ දෙවැනි post එක ගෙනාව</span></span></span></p><p><span style="font-size: 12px"><span style="font-size: 12px"><span style="font-size: 12px"></span></span></span></p><p><span style="font-size: 12px"><span style="font-size: 12px"><span style="font-size: 12px"></span></span></span></p><p><span style="font-size: 12px"><span style="font-size: 12px"><span style="font-size: 12px">බලපු නැති අය පලවෙනි එක මෙතනින් බලන්න - <a href="http://www.elakiri.com/forum/showthread.php?p=19014715#post19014715" target="_blank">http://www.elakiri.com/forum/showthread.php?p=19014715#post19014715</a></span></span></span></p><p><span style="font-size: 12px"><span style="font-size: 12px"><span style="font-size: 12px"></span></span></span></p><p><span style="font-size: 12px"><span style="font-size: 12px"><span style="font-size: 12px"></span></span></span></p><p><span style="font-size: 12px"><span style="font-size: 12px"><span style="font-size: 12px">අපි පොඩි app එකක් හදමු...මෙන්න මේක</span></span></span></p><p><span style="font-size: 12px"><span style="font-size: 12px"><span style="font-size: 12px"></span></span></span></p><p><span style="font-size: 12px"><span style="font-size: 12px"></span></span></p><p><span style="font-size: 12px"><span style="font-size: 12px"></span></span></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://3.bp.blogspot.com/-dV-f6ndh_ZM/Vgiy_lJHsUI/AAAAAAAAA28/k-q4DWhcJfg/s1600/38.PNG" target="_blank"><img src="https://3.bp.blogspot.com/-dV-f6ndh_ZM/Vgiy_lJHsUI/AAAAAAAAA28/k-q4DWhcJfg/s320/38.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">මේ app එකේ text එකක් type කරල show button එක click කලාම text කියන තැන ඒක පෙන්නන්න ඕනේ..clear button click කළාම ආයෙම text කියල වැටෙන්න ඕනේ..</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">Android Studio [FONT=&quot]එක open කරන්න...[/FONT]</span></p><p></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://4.bp.blogspot.com/-KnqIFMbAl08/VgeYkAhRnSI/AAAAAAAAAvI/moBUdmBeMGw/s1600/1.PNG" target="_blank"><img src="https://4.bp.blogspot.com/-KnqIFMbAl08/VgeYkAhRnSI/AAAAAAAAAvI/moBUdmBeMGw/s320/1.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">[FONT=&quot]wellcome window එකක් ඒවි..එකෙන් Start a new android studio project දෙන්න[/FONT]</span></p><p><span style="font-size: 12px"> </span></p><p><span style="font-size: 12px"></span></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://3.bp.blogspot.com/-0W5hB3z7Y5E/VgeY9QgeHTI/AAAAAAAAAwY/y6vpG6qrkYg/s1600/2.PNG" target="_blank"><img src="https://3.bp.blogspot.com/-0W5hB3z7Y5E/VgeY9QgeHTI/AAAAAAAAAwY/y6vpG6qrkYg/s1600/2.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">ඊළගට එන window එකෙන් app එකට නමක් දෙන්න..package name එකට කැමති නමක් දෙන්න.අගට .com කියන එක තියන්න..</span></p><p><span style="font-size: 12px"></span></p><p></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://1.bp.blogspot.com/-I1klDvCzjdY/VgeZJpWMyZI/AAAAAAAAAx0/ro5heMDly3o/s1600/3.PNG" target="_blank"><img src="https://1.bp.blogspot.com/-I1klDvCzjdY/VgeZJpWMyZI/AAAAAAAAAx0/ro5heMDly3o/s1600/3.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">මෙතනින් minimum sdk එක ඒ කියන්නේ ඔයා ලියන app එක run වෙන්න ඕනේඅවම os level එක..මේක ice cream sandwitch තියන්න</span></p><p><span style="font-size: 12px"></span></p><p></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://3.bp.blogspot.com/-kCzR4uuVKh0/VgeZfZ1eGCI/AAAAAAAAAzQ/3YNIlxIxl7U/s1600/4.PNG" target="_blank"><img src="https://3.bp.blogspot.com/-kCzR4uuVKh0/VgeZfZ1eGCI/AAAAAAAAAzQ/3YNIlxIxl7U/s1600/4.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">දැන් එන්නේ app එකට activity එකක් add කරගන්න window එක..මෙතනින් blank activity එකක් add කරගන්න...activity එකක් කියන්නේ java class එකක්..එකේ තමා අපි app එකට අදාල codings ලියන්නේ</span></p><p><span style="font-size: 12px"></span></p><p></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://4.bp.blogspot.com/-idO_jJdCFlM/VgeZxE4poII/AAAAAAAAA0o/nbV1whky5Aw/s1600/5.PNG" target="_blank"><img src="https://4.bp.blogspot.com/-idO_jJdCFlM/VgeZxE4poII/AAAAAAAAA0o/nbV1whky5Aw/s1600/5.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">මෙතනින් අපේ activity එකට නමක් දෙන්න..ඊට පහලින් තියෙන්නේ layout එකේ නම එකත් කැමති නමක් දෙන්න..මම activity එක main විදියටත්..layout එක main_layout විදියටත් තියන්න...finish කරන්න</span></p><p><span style="font-size: 12px"></span></p><p></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://2.bp.blogspot.com/-2YzcNdhzBvk/VgeZ1bJEvBI/AAAAAAAAA04/ecoR3Lf6fX4/s1600/6.PNG" target="_blank"><img src="https://2.bp.blogspot.com/-2YzcNdhzBvk/VgeZ1bJEvBI/AAAAAAAAA04/ecoR3Lf6fX4/s1600/6.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">project එක create වෙන්න ටිකක් වෙලා යාවි</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://2.bp.blogspot.com/-n-zmWfaSc_M/VgeZ1wzeN4I/AAAAAAAAA08/ZXVf89Azksk/s1600/7.PNG" target="_blank"><img src="https://2.bp.blogspot.com/-n-zmWfaSc_M/VgeZ1wzeN4I/AAAAAAAAA08/ZXVf89Azksk/s1600/7.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p> <p style="text-align: center"></p> <p style="text-align: center"><span style="font-size: 12px"><a href="http://1.bp.blogspot.com/-TKoaITcTMbc/VgeZ2S3tHYI/AAAAAAAAA1E/15Hif_tpBYs/s1600/8.PNG" target="_blank"><img src="https://1.bp.blogspot.com/-TKoaITcTMbc/VgeZ2S3tHYI/AAAAAAAAA1E/15Hif_tpBYs/s1600/8.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">android sutdio open වෙලා rendering කියල වැටේවි..</span></p><p><span style="font-size: 12px"></span></p><p></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://3.bp.blogspot.com/-kFK9ILAtXWU/VgeZ6gsBT6I/AAAAAAAAA1Q/Z6D9JYRYb0M/s1600/9.PNG" target="_blank"><img src="https://3.bp.blogspot.com/-kFK9ILAtXWU/VgeZ6gsBT6I/AAAAAAAAA1Q/Z6D9JYRYb0M/s1600/9.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">ඊට පස්සේ xml file එකේ නැත්තන් layout file එකේ view එකක් පෙන්නයි..මේ view එක තමා කලින් render වුනේ..ඔයාලට rendering problem කියල error එකක් වැටුනොත් apptheme button එකෙන් theme එක මාරු කරන්න</span></p><p></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://1.bp.blogspot.com/-kRT36KhIP1s/Vgemh99dg_I/AAAAAAAAA10/qm8otQ0gde0/s1600/15.PNG" target="_blank"><img src="https://1.bp.blogspot.com/-kRT36KhIP1s/Vgemh99dg_I/AAAAAAAAA10/qm8otQ0gde0/s1600/15.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">මේ තියෙන්නේ android studio window එකේ ප්රධාන කොටස් ටික..රතු පාටින් කොටු කරලා තියෙන්නේ දැනට open වෙලා තියෙන main_layout file එකේ design view එක code එක බලන්න ඕනෙනම් Text ටැබ් එක(දෙවැනි රතු කොටුව) click කරන්න..ඔය ඉලක්කම් දාල තියෙන කොටස් වලින් palette window, component tree එක සහ properties window එක අදාළ වෙන්නේ xml file වල design ටැබ් එක open කලාම විතරයි..නැත්තන් ඒවා පෙන්නන්නේ නැහැ</span></p><p><span style="font-size: 12px"></span></p><p></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://4.bp.blogspot.com/-8gqDlDdeV0Y/Vgg6zxsAhOI/AAAAAAAAA2Q/o0sIYKUFNiM/s1600/10.PNG" target="_blank"><img src="https://4.bp.blogspot.com/-8gqDlDdeV0Y/Vgg6zxsAhOI/AAAAAAAAA2Q/o0sIYKUFNiM/s1600/10.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p> <p style="text-align: center"><span style="font-size: 12px"><a href="http://3.bp.blogspot.com/-p2Wel4mXe-E/Vgg47pK_OKI/AAAAAAAAA2E/RfO11RXUnzo/s1600/10.PNG" target="_blank"></a></span></p> <p style="text-align: center"><span style="font-size: 12px"><a href="http://3.bp.blogspot.com/-p2Wel4mXe-E/Vgg47pK_OKI/AAAAAAAAA2E/RfO11RXUnzo/s1600/10.PNG" target="_blank"></a></span></p><p><span style="font-size: 12px">01 project window</span></p><p><span style="font-size: 12px">මේකේ තමයි projects පෙන්නන්නේ..project එක expand කලාම ප්රධාන කොටස් තුනක් පෙන්නනවා.ඒ තමයි manifests file එක,java classes සහ අනිත් resources..xml files,grapics,icons වගේ දේවල් තියෙන්නේ resources වල</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">02 palette</span></p><p><span style="font-size: 12px">මේකේ තමයි අපිට අවශ්ය component තියෙන්නේ..අවශ්ය component ඇදල design එක උඩට දාල සිංහලෙන් කියනවනම් drag and drop කරලා හදා ගන්න පුළුවන්</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">03 properties window</span></p><p><span style="font-size: 12px">component එකක් උඩ click කරලා මේ window එක හරහා ඒ අදාළ component වල properties වෙනස් කරගන්න පුලුවන්. code එකෙනුත් කරන්නත් පුළුවන් </span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">04 Menu bar</span></p><p><span style="font-size: 12px">මේ bar එකේ තියෙන්නේ categorize කරපු menus ටිකක්.</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">05 Tool bar</span></p><p><span style="font-size: 12px">නිතරම භාවිතා වෙන tools ටික තමයි මෙතන තියෙන්නේ..tool උඩට mouse pointer එක ගෙනිච්චම පොඩි බැලූන් මෙනු එකක නම පෙන්නනවා</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">06</span></p><p><span style="font-size: 12px">අපේ design එකේ තියෙන component ටික පෙන්නන්නේ මෙතන..component පෙන්නන්නේ ඒවා design එකේ තියෙන පිළිවෙලට..ඒ ඒ layout වලට අදාල component ඒ ඒ layout ඇතුලේ තියෙන්නේ..</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://3.bp.blogspot.com/-rMzqvRcRPWI/VgeYsXAFsdI/AAAAAAAAAvQ/xbf4wnEfvVE/s1600/10.PNG" target="_blank"><img src="https://3.bp.blogspot.com/-rMzqvRcRPWI/VgeYsXAFsdI/AAAAAAAAAvQ/xbf4wnEfvVE/s1600/10.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">දැන් xml layout එකේ code එක open කරන්න..code ටැබ් එකෙන්..එතකොට code එක බලාගන්න පුළුවන්..අලුත් window එකක් එනවා දකුණු පැත්තෙන්..preview window එක..අපි code එකෙන් කරන වෙනස්කම් එවලේම මෙතන පෙන්නනවා</span></p><p></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://4.bp.blogspot.com/-GGRmhj6xs3I/VgiqOtuzDXI/AAAAAAAAA2g/6jDxQ9sPwFw/s1600/Capture.PNG" target="_blank"><img src="https://4.bp.blogspot.com/-GGRmhj6xs3I/VgiqOtuzDXI/AAAAAAAAA2g/6jDxQ9sPwFw/s1600/Capture.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://2.bp.blogspot.com/-LR7ow3aCCEs/VgeYz7yakLI/AAAAAAAAAvY/_Vg2IklYw3g/s1600/11.PNG" target="_blank"><img src="https://2.bp.blogspot.com/-LR7ow3aCCEs/VgeYz7yakLI/AAAAAAAAAvY/_Vg2IklYw3g/s1600/11.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">මම code එකේ පොඩි වෙනස්කම් ටිකක් කරනවා..මේ දාන්නේ වෙනස් කරපු හෝ අලුතින් එකතු කරපුවා.තියෙන අනිත් code මකන්න එපා..</span></p><p></p><p><span style="font-size: 12px">android:text="Text" විදියටත් </span></p><p><span style="font-size: 12px">android:layout_width="match_parent" විදියටත් වෙනස් කරගන්නවා..</span></p><p><span style="font-size: 12px">මුල් code එක වෙනස් කලාම helloworld කියන text එක Text විදියට වෙනස් වේවි..ඊට පස්සේ code එකෙන් textview එකේ size එක display එකේ දිගට සමාන දිගක් ගනීවි..</span></p><p><span style="font-size: 12px">මේ code වලින් අපි මේ component එකේ attributes අපිට ඕනේ විදියට වෙනස් කරගන්න එකයි කරන්නේ..properties window එක හරහාත් මේක කරගන්න පුළුවන්..එතකොට මේ code ටික android studio එකෙන් auto generate කරනවා..ඊලග post එකෙන් මේ ගැන වැඩිදුර විස්තර දාන්නම්..දැනට දල අදහසක් ගන්න</span></p><p></p><p><span style="font-size: 12px">android:layout_marginTop="20dp" - top margin එක dp 20ක් දාගත්ත..dp කියන්නේ Density-independent Pixels කියන එක..මේ ගැනත් ඊලග post එකෙන් පැහැදිලි කරන්නම්</span></p><p><span style="font-size: 12px"></span></p><p></p><p><span style="font-size: 12px">android:textSize="40dp" - text එකේ size එක dp 40ක් කරගත්ත</span></p><p><span style="font-size: 12px">android:gravity="center_horizontal" - text එක center allign කරගත්තා..</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">android:id="@+id/View1" - මේ textview එකට id එකක් දුන්නා.id එකක් දෙන්නේ code කරද්දී මේ component වෙන් කරලා හදුනාගන්න..</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://3.bp.blogspot.com/-y3LpfTZnD8w/Vgirc_CcJTI/AAAAAAAAA2s/lf-FSRCdyTA/s1600/12.PNG" target="_blank"><img src="https://3.bp.blogspot.com/-y3LpfTZnD8w/Vgirc_CcJTI/AAAAAAAAA2s/lf-FSRCdyTA/s1600/12.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p> <p style="text-align: center"><span style="font-size: 12px"><a href="http://3.bp.blogspot.com/-_orWjhhjLlo/VgeY3H8yNiI/AAAAAAAAAvg/UXROhuRyv5A/s1600/12.PNG" target="_blank"></a></span></p> <p style="text-align: center"><span style="font-size: 12px"><a href="http://3.bp.blogspot.com/-_orWjhhjLlo/VgeY3H8yNiI/AAAAAAAAAvg/UXROhuRyv5A/s1600/12.PNG" target="_blank"></a></span></p><p><span style="font-size: 12px"> මම ආයෙත් design view එකට ගිහින් palette එකේ Text Fields කියන category එකේ තියෙන palin text එකක් drag and drop කරගන්නවා..</span></p><p><span style="font-size: 12px"></span></p><p></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://1.bp.blogspot.com/-1HuKmNiqs7Q/VgebVKM8OnI/AAAAAAAAA1c/6P533NjbUUI/s1600/13.png" target="_blank"><img src="https://1.bp.blogspot.com/-1HuKmNiqs7Q/VgebVKM8OnI/AAAAAAAAA1c/6P533NjbUUI/s1600/13.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px"> ඊට පහලින් Widgets කියන category එකේ තියෙන button එකක් drag and drop කරගන්නවා..</span></p><p></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://1.bp.blogspot.com/-c23l0wsf1H0/VgeY47V1ICI/AAAAAAAAAvo/TvH_cR-eD-E/s1600/14.png" target="_blank"><img src="https://1.bp.blogspot.com/-c23l0wsf1H0/VgeY47V1ICI/AAAAAAAAAvo/TvH_cR-eD-E/s1600/14.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">මේ විදිහට පෙනේවි දැන්</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://1.bp.blogspot.com/-K9LbOVh_jGQ/VgeY5TpHitI/AAAAAAAAAvs/Ufr4Sb8m5GM/s1600/15.PNG" target="_blank"><img src="https://1.bp.blogspot.com/-K9LbOVh_jGQ/VgeY5TpHitI/AAAAAAAAAvs/Ufr4Sb8m5GM/s1600/15.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">දැන් මම ආයේ code එකට යනවා..දැන් පේනවා මේ edittext ඒ කියන්නේ textfield එක සහ button වලට අදාල code auto generate වෙලා තියෙනවා..මම මෙවගේත් අර attributes ටිකම වෙනස් කරගන්නවා..</span></p><p><span style="font-size: 12px">පහලින් වෙනස් කරපු code කොටස් දාන්නම්..මේ දාන්නේ වෙනස් කරපු හෝ අලුතින් එකතු කරපුවා.තියෙන අනිත් code මකන්න එපා..</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"><EditText</span></p><p><span style="font-size: 12px"> android:layout_width="match_parent"</span></p><p><span style="font-size: 12px"> android:id="@+id/tf"</span></p><p><span style="font-size: 12px"> android:layout_marginTop="20dp"</span></p><p><span style="font-size: 12px"> android:textSize="20dp"</span></p><p><span style="font-size: 12px"> android:gravity="center_horizontal"/></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"> <Button</span></p><p><span style="font-size: 12px"> android:layout_width="match_parent"</span></p><p><span style="font-size: 12px"> android:text="Show"</span></p><p><span style="font-size: 12px"> android:id="@+id/but1"</span></p><p><span style="font-size: 12px"> android:layout_below="@+id/tf" </span></p><p><span style="font-size: 12px">මෙතන කියන්නේ මේ button එක තියෙන්නේ edittext එකට පහලින් කියල..අපි edittext එකේ id එක වෙනස් කලානේ tf කියල..මෙතනත් ඒ id එක දෙන්න ඕනේ</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"> android:layout_marginTop="20dp"</span></p><p><span style="font-size: 12px"> android:textSize="20dp"</span></p><p><span style="font-size: 12px"> android:gravity="center_horizontal"/></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://2.bp.blogspot.com/-7_3FG3DEzbM/VgeY5sQhXQI/AAAAAAAAAv0/hI3VNSlbWcs/s1600/16.PNG" target="_blank"><img src="https://2.bp.blogspot.com/-7_3FG3DEzbM/VgeY5sQhXQI/AAAAAAAAAv0/hI3VNSlbWcs/s1600/16.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">තව පොඩි button එකක් දාගන්න ඕනනේ..textclear කරගන්න..මම තියෙන button එකේ code එක copy කරලා ඊට පහලින් paste කරගන්නවා..දැන් වෙනස් කරගන්නවා.මේ දාන්නේ වෙනස් කරපු හෝ අලුතින් එකතු කරපුවා.තියෙන අනිත් code මකන්න එපා..</span></p><p></p><p><span style="font-size: 12px"><Button</span></p><p><span style="font-size: 12px"> android:layout_width="match_parent"</span></p><p><span style="font-size: 12px"> android:text="Clear"</span></p><p><span style="font-size: 12px"> android:id="@+id/but2"</span></p><p><span style="font-size: 12px"> android:layout_below="@+id/but1"</span></p><p><span style="font-size: 12px"> android:layout_marginTop="20dp"</span></p><p><span style="font-size: 12px"> android:textSize="20dp"</span></p><p><span style="font-size: 12px"> android:gravity="center_horizontal"/></span><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://4.bp.blogspot.com/-U4RY6zmy75U/VgeY6DXvH2I/AAAAAAAAAv8/5JsQ6jPPHaw/s1600/17.PNG" target="_blank"><img src="https://4.bp.blogspot.com/-U4RY6zmy75U/VgeY6DXvH2I/AAAAAAAAAv8/5JsQ6jPPHaw/s1600/17.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">දැන් මම java class එකේ වැඩ පටන් ගන්නවා..මේ class එකේ override කරපු methods හතරක් පෙන්න තියෙනවා..මෙතනින් එක method එකයි අපි අද වැඩේට පාවිච්චි කරන්නේ..on create method එක..ජාවා app ලියද්දි constructor එකේ වෙන වැඩේ තමයි මේ method එකේ වෙන්නේ..ඒ කියන්නේ app එක ස්ටාර්ට් වෙනකොට වෙන්න ඕනේ දේවල් මෙතන ලියන්නේ</span><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://1.bp.blogspot.com/-1RFwENb4n44/VgeY7PKu7KI/AAAAAAAAAwI/cJZYmYEG0cs/s1600/18.PNG" target="_blank"><img src="https://1.bp.blogspot.com/-1RFwENb4n44/VgeY7PKu7KI/AAAAAAAAAwI/cJZYmYEG0cs/s1600/18.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">මුලින්ම අපි xml file එකේ හදපු component ටිකට reference ටිකක් define කරගන්න ඕන.</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">සරලව කිව්වොත් අර xml file එකේ දීපු id වලින් කතාකලාට කෙලින්ම මෙයාලව access කරන්න බැහැ..මොකද මෙයාල ඉන්නේ java class එකෙන් පිට නිසා..ඒ නිසා එයාල වගේ කට්ටියගේ object එකක් මේ class එකේ හදලා ඒ නම් වලින් xml file එකේ component ටික අල්ල ගන්න ඕනේ..එතකොට ඒ object එක හරහා අර component access කරන්න පුළුවන්..මෙතන කරන්නේ හදන එක..</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">මේක කරන්නේ class එක ඇතුලේ..method වල නෙවේ..oncreate method එකට උඩින් හදා ගන්නකෝ</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">button වල b1,b2 කියලා මම කමා දාල දෙකක් define කලේ..දෙපාරකට define නොකර එකම code එකෙන්</span></p><p></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://4.bp.blogspot.com/-73Sk8BDBErM/VgeY7TY9wzI/AAAAAAAAAwM/O-9Sp43i6P8/s1600/19.PNG" target="_blank"><img src="https://4.bp.blogspot.com/-73Sk8BDBErM/VgeY7TY9wzI/AAAAAAAAAwM/O-9Sp43i6P8/s1600/19.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p><span style="font-size: 12px">දැන් ඒ හදාගත්තු reference ටිකට xml file එකේ component ටික initialize කරන්න ඕනේ.</span></p><p><span style="font-size: 12px">සරලව කිව්වොත් xml file එකේ component ටික අල්ල ගන්න ඕනේ.</span></p><p></p><p><span style="font-size: 12px">මම එක code පේලියක් පැහැදිලි කරන්නම්</span></p><p><span style="font-size: 12px">b1=(Button)findViewById(R.id.but1);</span></p><p><span style="font-size: 12px">b1 කියන්නේ හදාගත්තු button refference එකක්..findViewById() කියන method එක පාවිච්චි කරනවා xml component එක හොයාගන්න..</span></p><p><span style="font-size: 12px">R.id.but1 කියන කොටසේ R කියන්නේ මේ අපි ලියන app එකේ auto generate උන java class එකක්..එකේ තමයි xml component ගැන විස්තර තියෙන්නේ..එකේ id වල but1 1 කියන xml component එක තමා R.id.but1 කියල ලිව්වේ..</span></p><p></p><p><span style="font-size: 12px">මම කිව්වනේ මේ class එකේ object එකක් හදල xml component එක අල්ල ගන්නවා කියල..ඇත්තටම වෙන්නේ auto generate වෙන R class එකෙන් තමා ඒ component අල්ලන් ඉන්නේ..අපි කරන්නේ R එකේ තියෙන component අල්ලගන්න එක</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://4.bp.blogspot.com/-7E5XIHL8wEs/VgeY-Ng02yI/AAAAAAAAAwg/dC-ZdZn6ug4/s1600/20.PNG" target="_blank"><img src="https://4.bp.blogspot.com/-7E5XIHL8wEs/VgeY-Ng02yI/AAAAAAAAAwg/dC-ZdZn6ug4/s1600/20.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">දැන් අපි show button එක click කරද්දී වෙන්නඕනේ දේ ලියාගන්නඕන..මුලින්මbutton එකට onclick listner එකක් දාගන්න ඕනේ</span></p><p><span style="font-size: 12px">සරලව කිව්වොත් මේ button එක ඔබනවද කියල අහන ඉන්න method එකක් දාගන්න ඕනේ.</span></p><p><span style="font-size: 12px"> onclick listner කියල class එකක් android api එකේ හදල තියෙන්නේ.එකේ තියෙනේ onclick කියන method එකෙන් අපිට මේ වැඩේ කරගත්තැහැකි..අපිට එක පාවිච්චි කරන්න විතරයි තියෙන්නේ</span></p><p></p><p><span style="font-size: 12px">මම මේ class එක implement කරගන්නවා onclick listner class එකට.implement කරනවා කියන එක නම් මෙතන පැහැදිලි කරන්නේ නැහැ..එක Java OOP වලට අදාළ දෙයක්..දන්නේ නැත්තන්..net search පාරක් දාන්න..සිංහලෙන් ලිපි තියනවා</span></p><p></p><p><span style="font-size: 12px">කරන්නේ මෙහෙමයි..code කරද්දී ctrl+space ගහල suggetion ගන්න</span></p><p><span style="font-size: 12px"></span></p><p></p><p><span style="font-size: 12px">public class Main extends AppCompatActivity මෙන්න මෙතන type කරන්න OnClickListener කියල {</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">ctrl+space ගහන්න</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">onclick listner දෙකක් පෙනේවි දාගන්න ඕනේ android view.View එක.</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">implement කලාම method override කරලා පාවිච්චි කරන්න ඕනේ..error පෙන්නන්නේ method override කරලා නැති නිසා</span></p><p><span style="font-size: 12px"></span></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://2.bp.blogspot.com/-Tmh8SHZgqNU/VgeY-lRqd9I/AAAAAAAAAwk/-BL3xhp5uHE/s1600/21.PNG" target="_blank"><img src="https://2.bp.blogspot.com/-Tmh8SHZgqNU/VgeY-lRqd9I/AAAAAAAAAwk/-BL3xhp5uHE/s1600/21.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">මම java class එකේ පහලම..ඒ කියන්නේ අවසාන සඟල වරහනට } උඩින්.click කරලා ctrl+o ඔබනවා</span></p><p><span style="font-size: 12px">එන window එකේ android view.View.OnClickListener යටතේ තියෙන onClick method එක select කරන්න</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://3.bp.blogspot.com/-oP4MvppQNd4/VgeZAEzedxI/AAAAAAAAAww/bZhCoFdATDE/s1600/22.PNG" target="_blank"><img src="https://3.bp.blogspot.com/-oP4MvppQNd4/VgeZAEzedxI/AAAAAAAAAww/bZhCoFdATDE/s1600/22.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">override උනා</span></p><p><span style="font-size: 12px"></span></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://2.bp.blogspot.com/-6YmwTzc7IXM/VgeZAUzXseI/AAAAAAAAAw0/v6H4vqFX6hM/s1600/23.PNG" target="_blank"><img src="https://2.bp.blogspot.com/-6YmwTzc7IXM/VgeZAUzXseI/AAAAAAAAAw0/v6H4vqFX6hM/s1600/23.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p></p><p><span style="font-size: 12px">ඒක ඇතුලේ swith case එකක් හදාගන්න</span></p><p><span style="font-size: 12px">case දෙකට දාගන්නේ..button දෙකේ id දෙක..(xml file එකේ දීපු id..මොකද ඒ button වල original id කියන්නේ xml file එකේ දීපු id.අනිත්ව ඒ කියන්නේ b1,b2 කියන්නේ අපි හදපු reference වල නම්)</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">switch (v.getId()){</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"> case R.id.but1:</span></p><p><span style="font-size: 12px"> මෙතන තමා but1 click කලාම වෙන්න ඕනේ මොනාද කියල ලියන්නේ </span></p><p><span style="font-size: 12px"> break;</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"> case R.id.but2:</span></p><p><span style="font-size: 12px"> මෙතන තමා but2 click කලාම වෙන්න ඕනේ මොනාද කියල ලියන්නේ </span></p><p><span style="font-size: 12px"> break;</span></p><p><span style="font-size: 12px"> }</span></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://2.bp.blogspot.com/-LNUSg9gReU4/VgeZBCWxJkI/AAAAAAAAAxA/h7Bd28O34DY/s1600/24.PNG" target="_blank"><img src="https://2.bp.blogspot.com/-LNUSg9gReU4/VgeZBCWxJkI/AAAAAAAAAxA/h7Bd28O34DY/s1600/24.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">දැන් button වලට අදාළ code ලියමු</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">switch (v.getId()){</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"> case R.id.but1:</span></p><p><span style="font-size: 12px"> tv1.setText(ed1.getText());</span></p><p><span style="font-size: 12px"> ed1.setText(null);</span></p><p><span style="font-size: 12px"> break;</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"> case R.id.but2:</span></p><p><span style="font-size: 12px"> tv1.setText("Text");</span></p><p><span style="font-size: 12px"> ed1.setText(null);</span></p><p><span style="font-size: 12px"> break;</span></p><p><span style="font-size: 12px"> }</span></p><p><span style="font-size: 12px"></span></p><p></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://2.bp.blogspot.com/-qXmzZlTuqPM/VgeZBvKpJ2I/AAAAAAAAAxI/h8G_QVP_VnE/s1600/25.PNG" target="_blank"><img src="https://2.bp.blogspot.com/-qXmzZlTuqPM/VgeZBvKpJ2I/AAAAAAAAAxI/h8G_QVP_VnE/s1600/25.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p><p><span style="font-size: 12px"> තව වැඩක් කරන්න ඕනේ.onclicklistner එක හැදුවට button වලට තාම onclicklistner එක දැම්මේ නෑනේ</span></p><p><span style="font-size: 12px">ඒක දාන්නේ oncreate එක ඇතුලේ</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">b1.setOnClickListener(this); - this කියන්නේ onclicklistner එක මේ class එකේම හදල තියෙන නිසා</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">b2.setOnClickListener(this);</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p style="text-align: center"><span style="font-size: 12px"><a href="http://3.bp.blogspot.com/-XrJkIi3bCvw/VgeZCAnHkMI/AAAAAAAAAxQ/cNmK9WOLcF8/s1600/25_2.PNG" target="_blank"><img src="https://3.bp.blogspot.com/-XrJkIi3bCvw/VgeZCAnHkMI/AAAAAAAAAxQ/cNmK9WOLcF8/s1600/25_2.PNG" alt="" class="fr-fic fr-dii fr-draggable " style="" /></a></span></p></blockquote><p></p>
[QUOTE="KRipTER, post: 19029631, member: 548168"] [SIZE=3][SIZE=3][SIZE=3]ඔන්න android නුලේ දෙවැනි post එක ගෙනාව[/SIZE] [SIZE=3] [/SIZE] [SIZE=3]බලපු නැති අය පලවෙනි එක මෙතනින් බලන්න - [URL]http://www.elakiri.com/forum/showthread.php?p=19014715#post19014715[/URL][/SIZE] [SIZE=3] [/SIZE] [SIZE=3]අපි පොඩි app එකක් හදමු...මෙන්න මේක [/SIZE] [/SIZE][/SIZE] [CENTER][SIZE=3][URL="http://3.bp.blogspot.com/-dV-f6ndh_ZM/Vgiy_lJHsUI/AAAAAAAAA28/k-q4DWhcJfg/s1600/38.PNG"][IMG]https://3.bp.blogspot.com/-dV-f6ndh_ZM/Vgiy_lJHsUI/AAAAAAAAA28/k-q4DWhcJfg/s320/38.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]මේ app එකේ text එකක් type කරල show button එක click කලාම text කියන තැන ඒක පෙන්නන්න ඕනේ..clear button click කළාම ආයෙම text කියල වැටෙන්න ඕනේ..[/SIZE] [SIZE=3] [/SIZE] [SIZE=3]Android Studio [FONT="]එක open කරන්න...[/FONT][/SIZE] [CENTER][SIZE=3][URL="http://4.bp.blogspot.com/-KnqIFMbAl08/VgeYkAhRnSI/AAAAAAAAAvI/moBUdmBeMGw/s1600/1.PNG"][IMG]https://4.bp.blogspot.com/-KnqIFMbAl08/VgeYkAhRnSI/AAAAAAAAAvI/moBUdmBeMGw/s320/1.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3][FONT="]wellcome window එකක් ඒවි..එකෙන් Start a new android studio project දෙන්න[/FONT][/SIZE] [SIZE=3] [/SIZE] [CENTER][SIZE=3][URL="http://3.bp.blogspot.com/-0W5hB3z7Y5E/VgeY9QgeHTI/AAAAAAAAAwY/y6vpG6qrkYg/s1600/2.PNG"][IMG]https://3.bp.blogspot.com/-0W5hB3z7Y5E/VgeY9QgeHTI/AAAAAAAAAwY/y6vpG6qrkYg/s1600/2.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]ඊළගට එන window එකෙන් app එකට නමක් දෙන්න..package name එකට කැමති නමක් දෙන්න.අගට .com කියන එක තියන්න.. [/SIZE] [CENTER][SIZE=3][URL="http://1.bp.blogspot.com/-I1klDvCzjdY/VgeZJpWMyZI/AAAAAAAAAx0/ro5heMDly3o/s1600/3.PNG"][IMG]https://1.bp.blogspot.com/-I1klDvCzjdY/VgeZJpWMyZI/AAAAAAAAAx0/ro5heMDly3o/s1600/3.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]මෙතනින් minimum sdk එක ඒ කියන්නේ ඔයා ලියන app එක run වෙන්න ඕනේඅවම os level එක..මේක ice cream sandwitch තියන්න [/SIZE] [CENTER][SIZE=3][URL="http://3.bp.blogspot.com/-kCzR4uuVKh0/VgeZfZ1eGCI/AAAAAAAAAzQ/3YNIlxIxl7U/s1600/4.PNG"][IMG]https://3.bp.blogspot.com/-kCzR4uuVKh0/VgeZfZ1eGCI/AAAAAAAAAzQ/3YNIlxIxl7U/s1600/4.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]දැන් එන්නේ app එකට activity එකක් add කරගන්න window එක..මෙතනින් blank activity එකක් add කරගන්න...activity එකක් කියන්නේ java class එකක්..එකේ තමා අපි app එකට අදාල codings ලියන්නේ [/SIZE] [CENTER][SIZE=3][URL="http://4.bp.blogspot.com/-idO_jJdCFlM/VgeZxE4poII/AAAAAAAAA0o/nbV1whky5Aw/s1600/5.PNG"][IMG]https://4.bp.blogspot.com/-idO_jJdCFlM/VgeZxE4poII/AAAAAAAAA0o/nbV1whky5Aw/s1600/5.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]මෙතනින් අපේ activity එකට නමක් දෙන්න..ඊට පහලින් තියෙන්නේ layout එකේ නම එකත් කැමති නමක් දෙන්න..මම activity එක main විදියටත්..layout එක main_layout විදියටත් තියන්න...finish කරන්න [/SIZE] [CENTER][SIZE=3][URL="http://2.bp.blogspot.com/-2YzcNdhzBvk/VgeZ1bJEvBI/AAAAAAAAA04/ecoR3Lf6fX4/s1600/6.PNG"][IMG]https://2.bp.blogspot.com/-2YzcNdhzBvk/VgeZ1bJEvBI/AAAAAAAAA04/ecoR3Lf6fX4/s1600/6.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]project එක create වෙන්න ටිකක් වෙලා යාවි[/SIZE] [SIZE=3] [/SIZE] [CENTER][SIZE=3][URL="http://2.bp.blogspot.com/-n-zmWfaSc_M/VgeZ1wzeN4I/AAAAAAAAA08/ZXVf89Azksk/s1600/7.PNG"][IMG]https://2.bp.blogspot.com/-n-zmWfaSc_M/VgeZ1wzeN4I/AAAAAAAAA08/ZXVf89Azksk/s1600/7.PNG[/IMG][/URL][/SIZE] [SIZE=3][URL="http://1.bp.blogspot.com/-TKoaITcTMbc/VgeZ2S3tHYI/AAAAAAAAA1E/15Hif_tpBYs/s1600/8.PNG"][IMG]https://1.bp.blogspot.com/-TKoaITcTMbc/VgeZ2S3tHYI/AAAAAAAAA1E/15Hif_tpBYs/s1600/8.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]android sutdio open වෙලා rendering කියල වැටේවි.. [/SIZE] [CENTER][SIZE=3][URL="http://3.bp.blogspot.com/-kFK9ILAtXWU/VgeZ6gsBT6I/AAAAAAAAA1Q/Z6D9JYRYb0M/s1600/9.PNG"][IMG]https://3.bp.blogspot.com/-kFK9ILAtXWU/VgeZ6gsBT6I/AAAAAAAAA1Q/Z6D9JYRYb0M/s1600/9.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]ඊට පස්සේ xml file එකේ නැත්තන් layout file එකේ view එකක් පෙන්නයි..මේ view එක තමා කලින් render වුනේ..ඔයාලට rendering problem කියල error එකක් වැටුනොත් apptheme button එකෙන් theme එක මාරු කරන්න[/SIZE] [CENTER][SIZE=3][URL="http://1.bp.blogspot.com/-kRT36KhIP1s/Vgemh99dg_I/AAAAAAAAA10/qm8otQ0gde0/s1600/15.PNG"][IMG]https://1.bp.blogspot.com/-kRT36KhIP1s/Vgemh99dg_I/AAAAAAAAA10/qm8otQ0gde0/s1600/15.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]මේ තියෙන්නේ android studio window එකේ ප්රධාන කොටස් ටික..රතු පාටින් කොටු කරලා තියෙන්නේ දැනට open වෙලා තියෙන main_layout file එකේ design view එක code එක බලන්න ඕනෙනම් Text ටැබ් එක(දෙවැනි රතු කොටුව) click කරන්න..ඔය ඉලක්කම් දාල තියෙන කොටස් වලින් palette window, component tree එක සහ properties window එක අදාළ වෙන්නේ xml file වල design ටැබ් එක open කලාම විතරයි..නැත්තන් ඒවා පෙන්නන්නේ නැහැ [/SIZE] [CENTER][SIZE=3][URL="http://4.bp.blogspot.com/-8gqDlDdeV0Y/Vgg6zxsAhOI/AAAAAAAAA2Q/o0sIYKUFNiM/s1600/10.PNG"][IMG]https://4.bp.blogspot.com/-8gqDlDdeV0Y/Vgg6zxsAhOI/AAAAAAAAA2Q/o0sIYKUFNiM/s1600/10.PNG[/IMG][/URL][/SIZE] [SIZE=3][URL="http://3.bp.blogspot.com/-p2Wel4mXe-E/Vgg47pK_OKI/AAAAAAAAA2E/RfO11RXUnzo/s1600/10.PNG"] [/URL][/SIZE][/CENTER] [SIZE=3]01 project window[/SIZE] [SIZE=3]මේකේ තමයි projects පෙන්නන්නේ..project එක expand කලාම ප්රධාන කොටස් තුනක් පෙන්නනවා.ඒ තමයි manifests file එක,java classes සහ අනිත් resources..xml files,grapics,icons වගේ දේවල් තියෙන්නේ resources වල[/SIZE] [SIZE=3] [/SIZE] [SIZE=3]02 palette[/SIZE] [SIZE=3]මේකේ තමයි අපිට අවශ්ය component තියෙන්නේ..අවශ්ය component ඇදල design එක උඩට දාල සිංහලෙන් කියනවනම් drag and drop කරලා හදා ගන්න පුළුවන්[/SIZE] [SIZE=3] [/SIZE] [SIZE=3]03 properties window[/SIZE] [SIZE=3]component එකක් උඩ click කරලා මේ window එක හරහා ඒ අදාළ component වල properties වෙනස් කරගන්න පුලුවන්. code එකෙනුත් කරන්නත් පුළුවන් [/SIZE] [SIZE=3] [/SIZE] [SIZE=3]04 Menu bar[/SIZE] [SIZE=3]මේ bar එකේ තියෙන්නේ categorize කරපු menus ටිකක්.[/SIZE] [SIZE=3] [/SIZE] [SIZE=3]05 Tool bar[/SIZE] [SIZE=3]නිතරම භාවිතා වෙන tools ටික තමයි මෙතන තියෙන්නේ..tool උඩට mouse pointer එක ගෙනිච්චම පොඩි බැලූන් මෙනු එකක නම පෙන්නනවා[/SIZE] [SIZE=3] [/SIZE] [SIZE=3]06[/SIZE] [SIZE=3]අපේ design එකේ තියෙන component ටික පෙන්නන්නේ මෙතන..component පෙන්නන්නේ ඒවා design එකේ තියෙන පිළිවෙලට..ඒ ඒ layout වලට අදාල component ඒ ඒ layout ඇතුලේ තියෙන්නේ.. [/SIZE] [SIZE=3] [/SIZE] [CENTER][SIZE=3][URL="http://3.bp.blogspot.com/-rMzqvRcRPWI/VgeYsXAFsdI/AAAAAAAAAvQ/xbf4wnEfvVE/s1600/10.PNG"][IMG]https://3.bp.blogspot.com/-rMzqvRcRPWI/VgeYsXAFsdI/AAAAAAAAAvQ/xbf4wnEfvVE/s1600/10.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]දැන් xml layout එකේ code එක open කරන්න..code ටැබ් එකෙන්..එතකොට code එක බලාගන්න පුළුවන්..අලුත් window එකක් එනවා දකුණු පැත්තෙන්..preview window එක..අපි code එකෙන් කරන වෙනස්කම් එවලේම මෙතන පෙන්නනවා[/SIZE] [CENTER][SIZE=3][URL="http://4.bp.blogspot.com/-GGRmhj6xs3I/VgiqOtuzDXI/AAAAAAAAA2g/6jDxQ9sPwFw/s1600/Capture.PNG"][IMG]https://4.bp.blogspot.com/-GGRmhj6xs3I/VgiqOtuzDXI/AAAAAAAAA2g/6jDxQ9sPwFw/s1600/Capture.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3] [/SIZE] [CENTER][SIZE=3][URL="http://2.bp.blogspot.com/-LR7ow3aCCEs/VgeYz7yakLI/AAAAAAAAAvY/_Vg2IklYw3g/s1600/11.PNG"][IMG]https://2.bp.blogspot.com/-LR7ow3aCCEs/VgeYz7yakLI/AAAAAAAAAvY/_Vg2IklYw3g/s1600/11.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]මම code එකේ පොඩි වෙනස්කම් ටිකක් කරනවා..මේ දාන්නේ වෙනස් කරපු හෝ අලුතින් එකතු කරපුවා.තියෙන අනිත් code මකන්න එපා..[/SIZE] [SIZE=3]android:text="Text" විදියටත් android:layout_width="match_parent" විදියටත් වෙනස් කරගන්නවා..[/SIZE] [SIZE=3]මුල් code එක වෙනස් කලාම helloworld කියන text එක Text විදියට වෙනස් වේවි..ඊට පස්සේ code එකෙන් textview එකේ size එක display එකේ දිගට සමාන දිගක් ගනීවි..[/SIZE] [SIZE=3]මේ code වලින් අපි මේ component එකේ attributes අපිට ඕනේ විදියට වෙනස් කරගන්න එකයි කරන්නේ..properties window එක හරහාත් මේක කරගන්න පුළුවන්..එතකොට මේ code ටික android studio එකෙන් auto generate කරනවා..ඊලග post එකෙන් මේ ගැන වැඩිදුර විස්තර දාන්නම්..දැනට දල අදහසක් ගන්න[/SIZE] [SIZE=3]android:layout_marginTop="20dp" - top margin එක dp 20ක් දාගත්ත..dp කියන්නේ Density-independent Pixels කියන එක..මේ ගැනත් ඊලග post එකෙන් පැහැදිලි කරන්නම් [/SIZE] [SIZE=3]android:textSize="40dp" - text එකේ size එක dp 40ක් කරගත්ත android:gravity="center_horizontal" - text එක center allign කරගත්තා..[/SIZE] [SIZE=3] android:id="@+id/View1" - මේ textview එකට id එකක් දුන්නා.id එකක් දෙන්නේ code කරද්දී මේ component වෙන් කරලා හදුනාගන්න.. [/SIZE] [SIZE=3] [/SIZE] [CENTER][SIZE=3][URL="http://3.bp.blogspot.com/-y3LpfTZnD8w/Vgirc_CcJTI/AAAAAAAAA2s/lf-FSRCdyTA/s1600/12.PNG"][IMG]https://3.bp.blogspot.com/-y3LpfTZnD8w/Vgirc_CcJTI/AAAAAAAAA2s/lf-FSRCdyTA/s1600/12.PNG[/IMG][/URL][/SIZE] [SIZE=3][URL="http://3.bp.blogspot.com/-_orWjhhjLlo/VgeY3H8yNiI/AAAAAAAAAvg/UXROhuRyv5A/s1600/12.PNG"] [/URL][/SIZE][/CENTER] [SIZE=3] මම ආයෙත් design view එකට ගිහින් palette එකේ Text Fields කියන category එකේ තියෙන palin text එකක් drag and drop කරගන්නවා.. [/SIZE] [CENTER][SIZE=3][URL="http://1.bp.blogspot.com/-1HuKmNiqs7Q/VgebVKM8OnI/AAAAAAAAA1c/6P533NjbUUI/s1600/13.png"][IMG]https://1.bp.blogspot.com/-1HuKmNiqs7Q/VgebVKM8OnI/AAAAAAAAA1c/6P533NjbUUI/s1600/13.png[/IMG][/URL][/SIZE][/CENTER] [SIZE=3] ඊට පහලින් Widgets කියන category එකේ තියෙන button එකක් drag and drop කරගන්නවා..[/SIZE] [CENTER][SIZE=3][URL="http://1.bp.blogspot.com/-c23l0wsf1H0/VgeY47V1ICI/AAAAAAAAAvo/TvH_cR-eD-E/s1600/14.png"][IMG]https://1.bp.blogspot.com/-c23l0wsf1H0/VgeY47V1ICI/AAAAAAAAAvo/TvH_cR-eD-E/s1600/14.png[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]මේ විදිහට පෙනේවි දැන්[/SIZE] [SIZE=3] [/SIZE] [CENTER][SIZE=3][URL="http://1.bp.blogspot.com/-K9LbOVh_jGQ/VgeY5TpHitI/AAAAAAAAAvs/Ufr4Sb8m5GM/s1600/15.PNG"][IMG]https://1.bp.blogspot.com/-K9LbOVh_jGQ/VgeY5TpHitI/AAAAAAAAAvs/Ufr4Sb8m5GM/s1600/15.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]දැන් මම ආයේ code එකට යනවා..දැන් පේනවා මේ edittext ඒ කියන්නේ textfield එක සහ button වලට අදාල code auto generate වෙලා තියෙනවා..මම මෙවගේත් අර attributes ටිකම වෙනස් කරගන්නවා..[/SIZE] [SIZE=3]පහලින් වෙනස් කරපු code කොටස් දාන්නම්..මේ දාන්නේ වෙනස් කරපු හෝ අලුතින් එකතු කරපුවා.තියෙන අනිත් code මකන්න එපා.. [/SIZE] [SIZE=3] [/SIZE] [SIZE=3]<EditText android:layout_width="match_parent" android:id="@+id/tf" android:layout_marginTop="20dp" android:textSize="20dp" android:gravity="center_horizontal"/> <Button android:layout_width="match_parent" android:text="Show" android:id="@+id/but1" android:layout_below="@+id/tf" [/SIZE] [SIZE=3]මෙතන කියන්නේ මේ button එක තියෙන්නේ edittext එකට පහලින් කියල..අපි edittext එකේ id එක වෙනස් කලානේ tf කියල..මෙතනත් ඒ id එක දෙන්න ඕනේ[/SIZE] [SIZE=3] android:layout_marginTop="20dp" android:textSize="20dp" android:gravity="center_horizontal"/> [/SIZE] [SIZE=3] [/SIZE] [CENTER][SIZE=3][URL="http://2.bp.blogspot.com/-7_3FG3DEzbM/VgeY5sQhXQI/AAAAAAAAAv0/hI3VNSlbWcs/s1600/16.PNG"][IMG]https://2.bp.blogspot.com/-7_3FG3DEzbM/VgeY5sQhXQI/AAAAAAAAAv0/hI3VNSlbWcs/s1600/16.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]තව පොඩි button එකක් දාගන්න ඕනනේ..textclear කරගන්න..මම තියෙන button එකේ code එක copy කරලා ඊට පහලින් paste කරගන්නවා..දැන් වෙනස් කරගන්නවා.මේ දාන්නේ වෙනස් කරපු හෝ අලුතින් එකතු කරපුවා.තියෙන අනිත් code මකන්න එපා..[/SIZE] [SIZE=3]<Button android:layout_width="match_parent" android:text="Clear" android:id="@+id/but2" android:layout_below="@+id/but1" android:layout_marginTop="20dp" android:textSize="20dp" android:gravity="center_horizontal"/>[/SIZE][SIZE=3] [/SIZE] [CENTER][SIZE=3][URL="http://4.bp.blogspot.com/-U4RY6zmy75U/VgeY6DXvH2I/AAAAAAAAAv8/5JsQ6jPPHaw/s1600/17.PNG"][IMG]https://4.bp.blogspot.com/-U4RY6zmy75U/VgeY6DXvH2I/AAAAAAAAAv8/5JsQ6jPPHaw/s1600/17.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]දැන් මම java class එකේ වැඩ පටන් ගන්නවා..මේ class එකේ override කරපු methods හතරක් පෙන්න තියෙනවා..මෙතනින් එක method එකයි අපි අද වැඩේට පාවිච්චි කරන්නේ..on create method එක..ජාවා app ලියද්දි constructor එකේ වෙන වැඩේ තමයි මේ method එකේ වෙන්නේ..ඒ කියන්නේ app එක ස්ටාර්ට් වෙනකොට වෙන්න ඕනේ දේවල් මෙතන ලියන්නේ[/SIZE][SIZE=3] [/SIZE] [CENTER][SIZE=3][URL="http://1.bp.blogspot.com/-1RFwENb4n44/VgeY7PKu7KI/AAAAAAAAAwI/cJZYmYEG0cs/s1600/18.PNG"][IMG]https://1.bp.blogspot.com/-1RFwENb4n44/VgeY7PKu7KI/AAAAAAAAAwI/cJZYmYEG0cs/s1600/18.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]මුලින්ම අපි xml file එකේ හදපු component ටිකට reference ටිකක් define කරගන්න ඕන.[/SIZE] [SIZE=3] [/SIZE] [SIZE=3]සරලව කිව්වොත් අර xml file එකේ දීපු id වලින් කතාකලාට කෙලින්ම මෙයාලව access කරන්න බැහැ..මොකද මෙයාල ඉන්නේ java class එකෙන් පිට නිසා..ඒ නිසා එයාල වගේ කට්ටියගේ object එකක් මේ class එකේ හදලා ඒ නම් වලින් xml file එකේ component ටික අල්ල ගන්න ඕනේ..එතකොට ඒ object එක හරහා අර component access කරන්න පුළුවන්..මෙතන කරන්නේ හදන එක.. [/SIZE] [SIZE=3] [/SIZE] [SIZE=3]මේක කරන්නේ class එක ඇතුලේ..method වල නෙවේ..oncreate method එකට උඩින් හදා ගන්නකෝ[/SIZE] [SIZE=3] [/SIZE] [SIZE=3]button වල b1,b2 කියලා මම කමා දාල දෙකක් define කලේ..දෙපාරකට define නොකර එකම code එකෙන්[/SIZE] [CENTER][SIZE=3][URL="http://4.bp.blogspot.com/-73Sk8BDBErM/VgeY7TY9wzI/AAAAAAAAAwM/O-9Sp43i6P8/s1600/19.PNG"][IMG]https://4.bp.blogspot.com/-73Sk8BDBErM/VgeY7TY9wzI/AAAAAAAAAwM/O-9Sp43i6P8/s1600/19.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]දැන් ඒ හදාගත්තු reference ටිකට xml file එකේ component ටික initialize කරන්න ඕනේ.[/SIZE] [SIZE=3]සරලව කිව්වොත් xml file එකේ component ටික අල්ල ගන්න ඕනේ.[/SIZE] [SIZE=3]මම එක code පේලියක් පැහැදිලි කරන්නම්[/SIZE] [SIZE=3]b1=(Button)findViewById(R.id.but1);[/SIZE] [SIZE=3]b1 කියන්නේ හදාගත්තු button refference එකක්..findViewById() කියන method එක පාවිච්චි කරනවා xml component එක හොයාගන්න..[/SIZE] [SIZE=3]R.id.but1 කියන කොටසේ R කියන්නේ මේ අපි ලියන app එකේ auto generate උන java class එකක්..එකේ තමයි xml component ගැන විස්තර තියෙන්නේ..එකේ id වල but1 1 කියන xml component එක තමා R.id.but1 කියල ලිව්වේ..[/SIZE] [SIZE=3]මම කිව්වනේ මේ class එකේ object එකක් හදල xml component එක අල්ල ගන්නවා කියල..ඇත්තටම වෙන්නේ auto generate වෙන R class එකෙන් තමා ඒ component අල්ලන් ඉන්නේ..අපි කරන්නේ R එකේ තියෙන component අල්ලගන්න එක [/SIZE] [SIZE=3] [/SIZE] [CENTER][SIZE=3][URL="http://4.bp.blogspot.com/-7E5XIHL8wEs/VgeY-Ng02yI/AAAAAAAAAwg/dC-ZdZn6ug4/s1600/20.PNG"][IMG]https://4.bp.blogspot.com/-7E5XIHL8wEs/VgeY-Ng02yI/AAAAAAAAAwg/dC-ZdZn6ug4/s1600/20.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]දැන් අපි show button එක click කරද්දී වෙන්නඕනේ දේ ලියාගන්නඕන..මුලින්මbutton එකට onclick listner එකක් දාගන්න ඕනේ[/SIZE] [SIZE=3]සරලව කිව්වොත් මේ button එක ඔබනවද කියල අහන ඉන්න method එකක් දාගන්න ඕනේ.[/SIZE] [SIZE=3] onclick listner කියල class එකක් android api එකේ හදල තියෙන්නේ.එකේ තියෙනේ onclick කියන method එකෙන් අපිට මේ වැඩේ කරගත්තැහැකි..අපිට එක පාවිච්චි කරන්න විතරයි තියෙන්නේ[/SIZE] [SIZE=3]මම මේ class එක implement කරගන්නවා onclick listner class එකට.implement කරනවා කියන එක නම් මෙතන පැහැදිලි කරන්නේ නැහැ..එක Java OOP වලට අදාළ දෙයක්..දන්නේ නැත්තන්..net search පාරක් දාන්න..සිංහලෙන් ලිපි තියනවා[/SIZE] [SIZE=3]කරන්නේ මෙහෙමයි..code කරද්දී ctrl+space ගහල suggetion ගන්න [/SIZE] [SIZE=3]public class Main extends AppCompatActivity මෙන්න මෙතන type කරන්න OnClickListener කියල { [/SIZE] [SIZE=3] [/SIZE] [SIZE=3]ctrl+space ගහන්න[/SIZE] [SIZE=3] [/SIZE] [SIZE=3]onclick listner දෙකක් පෙනේවි දාගන්න ඕනේ android view.View එක.[/SIZE] [SIZE=3] [/SIZE] [SIZE=3] [/SIZE] [SIZE=3]implement කලාම method override කරලා පාවිච්චි කරන්න ඕනේ..error පෙන්නන්නේ method override කරලා නැති නිසා [/SIZE] [CENTER][SIZE=3][URL="http://2.bp.blogspot.com/-Tmh8SHZgqNU/VgeY-lRqd9I/AAAAAAAAAwk/-BL3xhp5uHE/s1600/21.PNG"][IMG]https://2.bp.blogspot.com/-Tmh8SHZgqNU/VgeY-lRqd9I/AAAAAAAAAwk/-BL3xhp5uHE/s1600/21.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]මම java class එකේ පහලම..ඒ කියන්නේ අවසාන සඟල වරහනට } උඩින්.click කරලා ctrl+o ඔබනවා[/SIZE] [SIZE=3]එන window එකේ android view.View.OnClickListener යටතේ තියෙන onClick method එක select කරන්න[/SIZE] [SIZE=3] [/SIZE] [CENTER][SIZE=3][URL="http://3.bp.blogspot.com/-oP4MvppQNd4/VgeZAEzedxI/AAAAAAAAAww/bZhCoFdATDE/s1600/22.PNG"][IMG]https://3.bp.blogspot.com/-oP4MvppQNd4/VgeZAEzedxI/AAAAAAAAAww/bZhCoFdATDE/s1600/22.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]override උනා [/SIZE] [CENTER][SIZE=3][URL="http://2.bp.blogspot.com/-6YmwTzc7IXM/VgeZAUzXseI/AAAAAAAAAw0/v6H4vqFX6hM/s1600/23.PNG"][IMG]https://2.bp.blogspot.com/-6YmwTzc7IXM/VgeZAUzXseI/AAAAAAAAAw0/v6H4vqFX6hM/s1600/23.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3]ඒක ඇතුලේ swith case එකක් හදාගන්න[/SIZE] [SIZE=3]case දෙකට දාගන්නේ..button දෙකේ id දෙක..(xml file එකේ දීපු id..මොකද ඒ button වල original id කියන්නේ xml file එකේ දීපු id.අනිත්ව ඒ කියන්නේ b1,b2 කියන්නේ අපි හදපු reference වල නම්)[/SIZE] [SIZE=3] [/SIZE] [SIZE=3]switch (v.getId()){ case R.id.but1: මෙතන තමා but1 click කලාම වෙන්න ඕනේ මොනාද කියල ලියන්නේ break; case R.id.but2: මෙතන තමා but2 click කලාම වෙන්න ඕනේ මොනාද කියල ලියන්නේ break; }[/SIZE] [CENTER][SIZE=3][URL="http://2.bp.blogspot.com/-LNUSg9gReU4/VgeZBCWxJkI/AAAAAAAAAxA/h7Bd28O34DY/s1600/24.PNG"][IMG]https://2.bp.blogspot.com/-LNUSg9gReU4/VgeZBCWxJkI/AAAAAAAAAxA/h7Bd28O34DY/s1600/24.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3] [/SIZE] [SIZE=3]දැන් button වලට අදාළ code ලියමු[/SIZE] [SIZE=3] [/SIZE] [SIZE=3]switch (v.getId()){ case R.id.but1: tv1.setText(ed1.getText()); ed1.setText(null); break; case R.id.but2: tv1.setText("Text"); ed1.setText(null); break; } [/SIZE] [CENTER][SIZE=3][URL="http://2.bp.blogspot.com/-qXmzZlTuqPM/VgeZBvKpJ2I/AAAAAAAAAxI/h8G_QVP_VnE/s1600/25.PNG"][IMG]https://2.bp.blogspot.com/-qXmzZlTuqPM/VgeZBvKpJ2I/AAAAAAAAAxI/h8G_QVP_VnE/s1600/25.PNG[/IMG][/URL][/SIZE][/CENTER] [SIZE=3] තව වැඩක් කරන්න ඕනේ.onclicklistner එක හැදුවට button වලට තාම onclicklistner එක දැම්මේ නෑනේ[/SIZE] [SIZE=3]ඒක දාන්නේ oncreate එක ඇතුලේ[/SIZE] [SIZE=3] [/SIZE] [SIZE=3]b1.setOnClickListener(this); - this කියන්නේ onclicklistner එක මේ class එකේම හදල තියෙන නිසා [/SIZE] [SIZE=3]b2.setOnClickListener(this); [/SIZE] [SIZE=3] [/SIZE] [CENTER][SIZE=3][URL="http://3.bp.blogspot.com/-XrJkIi3bCvw/VgeZCAnHkMI/AAAAAAAAAxQ/cNmK9WOLcF8/s1600/25_2.PNG"][IMG]https://3.bp.blogspot.com/-XrJkIi3bCvw/VgeZCAnHkMI/AAAAAAAAAxQ/cNmK9WOLcF8/s1600/25_2.PNG[/IMG][/URL][/SIZE][/CENTER] [/QUOTE]
Insert quotes…
Verification
Winadiyakata thappara keeyak tibeda?
Post reply
Top
Bottom