The layout we designed previously does not have to interact with each other automatically; let's make it happen. To put in simple words, when we execute the project, clicking on the button on the app will not trigger any action. We need to add the code for the interactions.
What we are trying to do is when the user taps on the button Display Name!, the app will capture any text inside the TextView
and produce a simple popup to display your name.
To achieve our goal let's play around, go to src
, double click on the package
folder and double click again on the file MainActivity.java
. This Java file will contain the code to load the layout of the XML file main_activity.xml
in order to create a UI. The Java code as follows is the default code provided by ADT.
You will see the package name on line one and several classes imported to the project. The code in line six is the main class declaration which inherits the Activity
class. method...