Android Application Buttons
This week I learned a bit more about the way Android applications are built. I started learning about the button objects in android development. A button is just what it sounds like a button you attach to the screen however the logic of the button is attached by your java file. In this week I decided to have different buttons on the screen and depending on what button the user clicks a toast message would appear. A toast message is just a message that appears that stays on your screen for 3 seconds the goes away. The toast message that I made appear just says "You have just clicked the (color) button". It may seem simple but there are many things going on in the background.
When I placed these button objects on the screen I attached an ID to them to make a connection to them in my java file. Once they are all properly identified I connect them in my java file by calling a built in method. Once I did that I implemented an interface that has a method called on onclick. Onclick allows you to provide logic to your object if the button is clicked. Once I did that I simply created a switch and every one of my cases it connected to every different color button on my screen. Once I did that I called another method that creates a toast message when the specific button is clicked. I am still learning how to create different activities on the same app and once I do I will create buttons that take you to different activities in the app.
Comments
Post a Comment