Focus on today's headlines-do the full stack siege Lion, learn the code to read, love the whole stack, more love life. Provide programmer technical and life guidance dry goods.
This series of courses is dedicated to veteran programmers who can quickly get started with Android development. System-wide from one. NET Programmer's perspective to summarize Android development in one step.
Previous lesson: Android Step by step from basics to mastery of self-paced tutorials, pure combat, pure Dry Goods (v)
Simple Calculator Program
How the foreground interface is associated with the background processing class.
In the last lesson we have finished building the calculator's front page, this time we will implement the real addition calculator function.
The development of the Android program is similar to the ASP. NET and WinForm we have studied, as well as the foreground page and the background processing program.
The corresponding Android processing program is here
I wonder if anyone has found out. These two correspond to the naming method or have some regularity. Yes. We put the background processing class name to: Xxxxactivity front-end interface in accordance with the ACTIVITY_XXX format written.
So what is activity?
The official argument is that the activity is a component of an application that provides a screen to interact with the user in order to do things like making a phone call, sending an email, and looking at a map.
We can understand that he is a window interface program. An activity includes backstage and foreground. Represents a Window component
We opened Mainactivity to uncover her mystery:
In fact, this is just a special inherited from: Appcompatactivity class.
We see that it contains a OnCreate method. The right Oncreat method is the entrance to the program.
The binding of the foreground page is set through the Setcontentview method. You may ask Setcontentview what the parameters mean. There's a r.layout.activity_main.
R represents a resource file. Can be said to represent is our res directory. R.layout.activity_main represents the Activity_main file under Res/layout but does not add the file extension.
So we are bound by this mainactivity is activity_main this front-page interface.
2. How does the foreground control relate to the background processing class?
1. To do a simple calculator project we need to get to the foreground control and then do the background processing.
2. Process: The foreground adds the ID, the background obtains to the control according to the ID, carries on the processing
Foreground control Add ID
Spooler gets the foreground control
You can get the object of the corresponding control by passing in the ID with the Findviewbyid method.
How to get the characters entered in a text box
Analysis Requirements:
Process: Get to text box 1 and text box 2 user input number, click the button 3 o'clock background will add the first two data, feedback to 4 display.
To make it simple:
Front Desk Interface:
button to set the Click event via the OnClick property.
Program code please async:
Https://yunpan.cn/cMLV6hmeTdeC6 Access Password e697
Welcome to the Headlines Today: Be the full-stack siege lion. This is a tutorial on learning Android development technology.
Next post:. NET programmers quickly learn how Android development-layout and click events are written
All-in-stack Engineer essentials: Android mobile Phone development, lesson six