Step 1: Install android Studio
Go to http://developer.android.com/sdk/index/html
to download
Step 2: open a new project
On the “Create New Project” window that opens, name your
project “Hello world”.
Note where the project file
location is and change it if desired.
Click “Next”.
Make sure on that Phone and Tablet is the only box that is
checked. Minimum SDK is below your phone’s operating system level.
Click “Next”.
Select “Blank Activity”.
Click “Next”.
Leave all of the activity name fields as they are.
Click “Finish”.
Note: it is typical naming convention in
android projects to so company name as some
Step 3: Edit the Welcome Message in the main activity
navigate to the activity_main.xml tab if it is not already open.
Make sure that the design tab is open on the
activity_main.xml display.
Click and drag the “Hello world” from the upper left corner
of the values phone display to the center of screen.
In the project file system on the left side is the window,
open the values folder.
In the file values folder, double-click the strings.xml
file.
In the file, find the line “Hello world”.
After the “Hello world” message, add “Welcome to my app”
Navigate back to the activity_main.xml tab.
Make sure that your centered text now read “Hello word
Welcome to my app”
Step 4: Add a button to the Main Activity
Navigate to the Design tab of the activity_main.xml display.
In the palette menu to the left of the phone display, find
Button (under the heading Widgets).
Click and drag button to be centered underneath your welcome
message.
Make sure your button is still selected.
In the Properties menu (on the left side of the window),
scroll sown to find the field for “text”.
Change the text from “New Button “to “Next page”.
Step 5: Create a Second Activity
At the top of the project’s file system tree, right click on
app.
Navigate through to new > Activity > Blank Activity.
Change the name of this activity to “second Activity.
Click Finish.
Make sure you are in the Design view of activity_second.xml
Drag the next box in the upper left of the phone display
down to the center as you did on the main Activity. A with the text box still
selected, find the ‘id’ field in the Properties menu on the right, and set it
to “text2”.
Open strings.xml again
Add a new line under “Hello world Welcome to my app” that
reads “Welcome to the second page”. Navigate back to activity_second.xml.
Select the box again.
In the properties pane, set the “text” field to
“@string/second_page”.
Make sure that text box now reads “Welcome to the second
page” and is in the center of the screen in the phone display.
No comments:
Post a Comment