官术网_书友最值得收藏!

  • Xamarin Blueprints
  • Michael Williams
  • 189字
  • 2021-07-08 11:48:19

Creating an Android project

Our first step is to create new general Android app:

The first screen you will land on is MainActivity. This is our starting activity, which will inflate the first user interface; take notice of the configuration attributes:

[Activity (Label = "Gallery.Droid", MainLauncher = true, Icon = "@mipmap/icon")] 

The MainLauncher flag indicates the starting activity; one activity must have this flag set to true so the application knows what activity to load first. The icon property is used to set the application icon, and the Label property is used to set the text of the application, which appears in the top left of the navigation bar:

namespace Gallery.Droid 
{ 
    using Android.App; 
    using Android.Widget; 
    using Android.OS; 
 
    [Activity (Label = "Gallery.Droid", MainLauncher = true, Icon = "@mipmap/icon")] 
    public class MainActivity : Activity 
    { 
        int count = 1; 
 
        protected override void OnCreate (Bundle savedInstanceState) 
        { 
            base.OnCreate (savedInstanceState); 
 
            // Set our view from the "main" layout resource 
            SetContentView (Resource.Layout.Main); 
        } 
    } 
} 

The formula for our activities is the same as Java; we must override the OnCreate method for each activity where we will inflate the first XML interface Main.xml.

主站蜘蛛池模板: 潜山县| 荆门市| 齐齐哈尔市| 无极县| 蓝山县| 达州市| 衡水市| 马鞍山市| 浮梁县| 江永县| 肥东县| 兴化市| 东丽区| 奉贤区| 贵溪市| 通州市| 淄博市| 崇阳县| 通山县| 巴彦县| 塔河县| 甘孜县| 招远市| 西宁市| 怀化市| 固原市| 临朐县| 兴海县| 金门县| 康乐县| 忻州市| 神农架林区| 永和县| 雷州市| 彰化市| 海门市| 武夷山市| 读书| 泌阳县| 九江市| 浦北县|