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)
          {
          }
      }
      
      

    . . . . . .

  • 相关阅读:
    H5调用本地摄像头
    zepto和jquery的区别,zepto的不同使用8条小结
    web前端页面性能优化小结
    超赞!聊聊WEB APP、HYBRID APP与NATIVE APP的设计差异
    activemq生产者和消费者的双向通信
    消息队列同步和异步机制
    postman使用教程
    spring boot mybatis sql打印到控制台
    spring boot 整合 mybatis 以及原理
    spring 框架整合mybatis的源码分析
  • 原文地址:https://www.cnblogs.com/Saints/p/8604364.html
Copyright © 2011-2022 走看看