How To Create Your First Android Application with Java
Create Your First Android Application with Java in Android Studio Integrated Development Environment (I.D.E).The App that I will be making in this video is the simplest one and perfect for beginners. Watch this video till the end to be able to understand it completely. You need some basic knowledge about Java to make an Android App. Hey Guys! Its Teja here! In this video, I will be teaching you how to create your first Android App in Java. In this video, I will be teaching you to make a simple clicker application for Android. This App is simple and it just shows us on what Button we clicked. Its perfect for beginners to get started with this simple application. DESIGN I will be using one TextView and three Buttons in this App, such that the TextView shows us the name of the button on which we clicked. The Three Buttons have the Text "A","B" and "C" respectively. So if we click on the first button with text "A", then the text in the text view is going to change as "A is clicked" and similarly with other two buttons. For simplicity, set the ID's of the three buttons as btn1,btn2 and btn3 respectively and TextView as txt in your activity_main.xml Coding Firstly, we need to add the four elements of the widget library(three buttons and one textview) to our activity_main.xml folder which represents the Layout of our Application. Then we need to link all these four elements to our Main Activity class. The MainActivity class is the first thing that is going to be executed when our Android App is executed. In the MainActivity class, we need to import the widget java package to be able to use the three buttons and one TextView that we used in the xml file(our Application Layout) To import the button class from the Widget library, use the code : import android.widget.Button; To import the TextView class from the widget Library, use the code : import android.widget.TextView; After importing these, you have to declare these in your Main Activity class. You can do that by simply saying : Button buttonA; Button buttonB; Button buttonC; TextView txtView; So, by the above four java declaration statements we declared three buttons and one text view. buttonA, buttonB and buttonC are the variable names of the three buttons of Button Datatype corresponding to the ID's btn1,btn2,btn3 respectively in activity_main.xml. txtView is the variable name for the TextView corresponding to the ID txt in activity_main.xml. The next thing is to set OnClick Listener to the three buttons. You can do so by typing : buttonA.setOnClickListener(this); buttonB.setOnClickListener(this); buttonC.setOnClickListener(this); Make sure that you implement OnClickListener to your MainActivity class. Now we can programatically know whenever the user clicks on any of the three buttons since we are listening to the clicks using OnClickListener. Next thing is, perform some activity whenever the user clicks on a Button in our Applciation. So, start a OnCreate method. This OnCreate method is going to be executed whenever the user clicks on any of the three buttons. And then, we are going to change the text of the textView basing on what button the user clicked using the setText() method. You can simply say : txtView.setText("text of the button that is clicked"); Thats it! Follow me on Instagram : https://www.instagram.com/teja.techraj/ Like my Facebook Page : http://fb.com/techraj156.com Follow me on Twitter : http://twitter.com/techraj156 Visit my Website : http://techraj156.com Email ID : anonymoushacker156@gmail.com Thanks For Watching! Cheers! -~-~~-~~~-~~-~- Please watch: "How the INTERNET actually works? " https://www.youtube.com/watch?v=U0mzA1AD_CY -~-~~-~~~-~~-~-