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

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.

主站蜘蛛池模板: 油尖旺区| 垦利县| 沙洋县| 沛县| 太仆寺旗| 尼玛县| 杭锦后旗| 西丰县| 凌云县| 剑河县| 通化市| 兴文县| 博爱县| 米泉市| 城市| 棋牌| 铁岭市| 广安市| 肥西县| 玉山县| 云梦县| 分宜县| 新郑市| 铜山县| 建水县| 海阳市| 星子县| 光泽县| 左权县| 修水县| 泰来县| 榆树市| 饶平县| 黔江区| 长丰县| 色达县| 镶黄旗| 丰原市| 安国市| 平邑县| 鹰潭市|