xamarin android 開發

開始環境vs2017 直接建立android 項目,左邊是android studio 的項目目錄  右邊是vs建立的android 項目目錄 結構基本相同,有res對應的Resources文件 android

 

加載佈局 git

android studio  setContentView(R.layout.activity_login)api

xamarin android   SetContentView(Resource.Layout.activity_login)網絡

項目中初始化控件基本寫法同樣框架

android studio    初始化控件Button btnGet =(Button)findViewById(R.id.btn_get); 不過如今基本使用ButterKnife ,到如今使用kotlin開發ButterKnife也不用了ide

xamarin android   初始化控件 Button btnGet = FindViewById<Button>(Resource.Id.btn_get);佈局

 

activity之間跳轉方法 this

Intent mIntent = new Intent(this,typeof(LoginActivity));
StartActivity(mIntent);3d

在要跳轉的界面加入  [Activity(ParentActivity = typeof(MainActivity))]blog

簡單寫了一下加載網絡圖片及請求api接口

加載圖片框架仍是延續了使用了glide 框架 請求接口使用了RestSharp 

加載網絡圖片 

//加載網絡圖片
Glide.With(this).Load("https://www.cnblogs.com/images/logo_small.gif").Into(ivPhoto);

 

接口請求

 項目源代碼地址  https://gitee.com/freexiaoyu/xamarinDemo  代碼壓縮包下載

相關文章
相關標籤/搜索