zoukankan      html  css  js  c++  java
  • 开篇

    与“原生”安卓开发不同的地方

    1. 程序入口:Activity属性标签设置了MainLauncher = true的Activity

    2. AndroidManifest.xml 位于Properties文件夹下

    3. view的事件处理直接使用委托

    4. 获取view的方式:使用泛型(见上图Button)

    5. Java的getter、setter被翻译成字段

    6. Intent-filter 在属性标签中设置

          [Activity(Label = "IntentFilterDemoActivity")]
          [IntentFilter(new[] { Intent.ActionGetContent }, Categories = new[] { Intent.CategoryDefault }, DataMimeType = "vnd.android.cursor.item/vnd.google.note")]
          public class IntentFilterDemoActivity : Activity
          {
              protected override void OnCreate(Bundle savedInstanceState)
              {
                  base.OnCreate(savedInstanceState);
      
                  // Create your application here
              }
          }
      

      生成的xml如下:

      <activity android:label="ResultDemoActivity" android:name="md5c6d828a91b42289b41de7c26628c84e9.ResultDemoActivity">
          <intent-filter>
              <action android:name="android.intent.action.GET_CONTENT" />
              <category android:name="android.intent.category.DEFAULT" />
              <data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
          </intent-filter>
      </activity>
      
    7. 在xml中定义的事件处理方法,需要加上[Java.Interop.Export("DoClick")]

          [Java.Interop.Export("DoClick")]
          public void DoClick(View view)
          {
              Toast.MakeText(this, "Clikced", ToastLength.Short).Show();
          }
      
    8. 自定义Application类
      在java里要只向AndroidManifest.xml里添加一句:

      <application android:icon="@drawable/icon" android:label="@string/app_name"
          android:name=".MyApplication">
      
      

      在Xamarin里,首先你要创建一个具有两个特殊参数的构造器的自定义Application类,同时要还加上[Application]的特性。

      [Application]
      public class MyApplication : Application
      {
          public MyApplication(IntPtr handle, JniHandleOwnership ownerShip) : base(handle, ownerShip)
          {
          }
      }
      
      

    . . . . . .

  • 相关阅读:
    python 爬取网络小说 清洗 并下载至txt文件
    2020.11.25收获
    2020.11.24收获
    2020.11.23收获
    2020.11.22收获
    2020.11.21收获
    Java学习11.21(使用 Servlet 完成控制)
    Java学习11.20
    Java学习11.19(学习servlet第三天)
    Java学习11.17(人口普查前端页面)
  • 原文地址:https://www.cnblogs.com/Saints/p/8604364.html
Copyright © 2011-2022 走看看