Thursday, October 6, 2011

Android Programming - Luas Bangun

I created (actually it based on someone tutorial and I modified it in some place, I can find the original link..) this very simple program to learn more about User Interface. How to layout, using Button, TextView and Edit Text. It is so simple, the function is to calculate the area of square, traingle and circle. User input the width, height or radius, and then the app calculate the area and show the result in a TextView.
Check out the source code in my GitHub. Here is the link.
1. As ussual create new project, I named it Luas Bangun, with LuasBangunActivity as a main activity.
2. Prepare AndroidManifest, create 3 new Activity from there, named it HitungLingkaran (for circle), HitungSegitiga (for triangle) and HitungPersegiPanjang (for square).
3. Let's begin templating. First create layout for LuasBangunActivity. It is in the main.xml file. You need to create three other XML file, one for each, lingkaran.xml (circle area), persegipanjang.xml (square area) and segitiga.xml (triangle area).
4. And then code the MainActivity. It is used for main screen, giving a link to another activity and exiting from application.
5. The lingkaran, persegipanjang and segitiga do not have any difference in programming structure, it is same, the difference is just the algorithm to calculate the area, and I think it will be easy, you know it from since elementary school.
6. Run your application, hope you found no error and I hope this example will help you a little to understand basic of User Interface in Android.





Categories: , , , ,

Related Posts:

  • Android Programming - Fast Way Preserving Sqlite DbActually this is some snippet I found from browsing, the guy who must be credited to this code is Omar Flores, sorry I can't found your link pal :). It helping me to copy already made SQLite database to my application, it mak… Read More
  • Install Conky di Ubuntu 11.04 Dulu sebenarnya saya sudah pernah sukses menginstall Conky di Ubuntu, dan sekarang saya mau mengulanginya. Untuk anda yang belum tahu Conky merupakan aplikasi yang mirip seperti Rainmeter di Windows platform. Conky bisa memb… Read More
  • Android Programming - Hello WorldOkay, the preparation phase is complete. You can now make Android Project. Let us start with the classic way in which a program Hello World. Let us immediately make, you need not know anything yet, we make first and I will… Read More
  • Android Programming - Luas BangunI created (actually it based on someone tutorial and I modified it in some place, I can find the original link..) this very simple program to learn more about User Interface. How to layout, using Button, TextView and Edit Tex… Read More
  • Android Programming - Access LocalhostWhen I developed an application that connect to my own web service ( I made my own simple web service too ^-^), I got this error "java.net.ConnectException localhost/127.0.0.1:8080 - Connection Refused". Hei, why my applicati… Read More

0 komentar:

Copyright © 2025 Johannes Dwi Cahyo | Powered by Blogger

Design by Anders Noren | Blogger Theme by NewBloggerThemes.com | BTheme.net      Up ↑