Although the environment is not stable, but can be developed, plus two environment variables do not know if there is no effect. Pending Test.
The two environment variables that are added are
① Add environment variable Android_sdk_home:
D:\Android\
② Append path under PATH environment variable:
D:\android\platform-tools;d:\android\tools;
Modified the virtual technology of the CPU
In general, it's interesting to write Android code in C #. The code style and writing is basically similar to what is written in Java, except that there are some methods that differ in name. Because I have not written the Android program has not developed a Java program, so there are errors in the place please point out.
Setcontentview (Resource.Layout.Main);
The default program comes up the first sentence is this, my English is not good, so understanding is probably meant to get the layout of the resource file.
One thing to note here is that if you drag a new control, but you don't get it on the CS code page, you can try to build the whole project from scratch, so you can bring it over. If you do not bring it, you may be prompted for error, so you need to pay attention.
Then drag the controls on the page to drag a few.
I dragged a few
Textview,edittext,button, respectively.
Because I've been doing web development before, so explain the bias webform.
TextView similar to label
EditText similar to text
button similar to button
My naming rules are basically all about using the web. If anyone knows this naming convention, you can tell me.
Let's take a look at some of the considerations for controls,
<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"android:orientation= "vertical"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"Android:minwidth= "25px"Android:minheight= "25px"> <TextViewAndroid:text= "Xiao Li"Android:layout_width= "Match_parent"Android:layout_height= "25.0DP"Android:id= "@+id/textview1" /> <EditTextAndroid:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:id= "@+id/txtphone"Android:text= "10086"Android:layout_margintop= "30.0DP" /> <ButtonAndroid:text= "Call"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:id= "@+id/btnphone"android:textsize= "25px" /> <ButtonAndroid:text= "Jump"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:id= "@+id/btnto" /></LinearLayout>
The size is expressed in pixels, and the alignment is expressed in DP. The DP can be of type float.
The ID name is @+id/youname.
VS's visual editing allows us to set them all on the properties. (VS2015 BUG Set font size may fail on the visual page, do not know why, it is not a problem to run) If you have learned Android development before, please ignore this paragraph .
Button Btnphone = findviewbyid<button>= findviewbyid<edittext> (Resource.Id.txtPhone);
Find the control with the ID of the view so that you can find the control and manipulate it, and C # side can add events to the control in two ways.
Delegate+ = Btnphone_click; Private void Btnphone_click (object sender, EventArgs e) { }
The own Hello World is the first type of delegation I feel the first kind of simple so I also have a few, the second is to write + = Press two tab generated.
Next, you can write your own code in the delegate or the method to perform the function operation. I made a little demo on the phone.
Btnphone.click + =Delegate { //Create whether type prompt box varCalldialog =NewAlertdialog.builder ( This); //Cue box informationCalldialog.setmessage ("do you want to start a call? "); //determining the text and events of a buttonCalldialog.setneutralbutton ("Call",Delegate { //Create a call event varCall =NewIntent (Intent.actioncall); //What's the number you want to call?Call. SetData (Android.Net.Uri.Parse ("Tel:"+txtphone.text)); //Perform this eventstartactivity (call); }); //Cancel text and events for a buttonCalldialog.setnegativebutton ("Cancel",Delegate { }); //show up. calldialog.show (); };
The way the code executes from top to bottom, you start by creating a hint box in the middle section we did some work on our cue box and finally showed the box. It feels like a form of CS, but it's not quite like it, but it's easy to understand.
This is the time to run, but make a few settings before running.
You need to call an interface (?) because you need to call. )
You also need to set the minimum executable Android version
Personal advice is best set to the version number of the simulator.
So you can make a phone call.
Now update to this, jump function next time say.
VS2015 Developing Android Application Note (i)