How to Create an Android App With Android Studio part 2

in #guides7 years ago

 Step 4: Add a Button to the Main Activity

 Navigate to the Design tab of the activity_main.xml display. 

  1. In the Palette menu to the left of the phone display, find Button (under the heading Widgets). 
  2. Click and drag Button to be centered underneath your welcome message. 
  3. Make sure your button is still selected. 
  4. In the Properties menu (on the right side of the window), scroll down to find the field for "text." 
  5.  Change the text from "New Button" to "Next Page." 

Step 5: Create a Second Activitynge the text from "New Button" to "Next Page."

 

 

  1. At the top of the project's file system tree, right click on "app."
  2. Navigate through to New > Activity > Blank Activity.
  3. Change the name of this activity to "SecondActivity".
  4. Click "Finish."
  5. Make sure you are in the Design view of activity_second.xml.
  6. Drag the text box in the upper left of the phone display down to the center as you did on the Main Activity.
  7. With the text box still selected, find the "id" field in the Properties menu on the right, and set it to "text2".
  8. Open strings.xml again.
  9. Add a new line under "Hello world! Welcome to my app!" that reads "Welcome to the second page!".
  10. Navigate back to activity_second.xml.
  11. Select the text box again.
  12. In the Properties pane, set the "text" field to "@string/second_page".
  13. Make sure that the text box now reads "Welcome to the second page!" and is in the center of the screen in the phone display.

More in the next tutorial

thanks


Sort:  

This post was resteemed by @resteembot!
Good Luck!

Learn more about the @resteembot project in the introduction post.

Coin Marketplace

STEEM 0.28
TRX 0.13
JST 0.032
BTC 61626.58
ETH 2940.28
USDT 1.00
SBD 3.66