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

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.

主站蜘蛛池模板: 乌恰县| 阜新市| 虹口区| 靖州| 湘潭县| 黔东| 福州市| 黑水县| 隆昌县| 美姑县| 盐源县| 利津县| 黄浦区| 鱼台县| 即墨市| 满洲里市| 三明市| 尚志市| 新乡市| 库伦旗| 建始县| 通榆县| 昂仁县| 杂多县| 金阳县| 邛崃市| 绩溪县| 城固县| 景宁| 宝山区| 沐川县| 麻江县| 黔东| 常州市| 水富县| 华坪县| 定南县| 龙游县| 石首市| 大埔县| 揭阳市|