xamarin android 开发

开始环境vs2017 直接创建android 项目,左边是android studio 的项目目录  右边是vs创建的android 项目目录 结构基本相同,有res对应的Resources文件 

 

加载布局 

android studio  setContentView(R.layout.activity_login)

xamarin android   SetContentView(Resource.Layout.activity_login)

项目中初始化控件基本写法一样

android studio    初始化控件Button btnGet =(Button)findViewById(R.id.btn_get); 不过现在基本使用ButterKnife ,到现在使用kotlin开发ButterKnife也不用了

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

 

activity之间跳转方法 

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

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

简单写了一下加载网络图片及请求api接口

加载图片框架还是延续了使用了glide 框架 请求接口使用了RestSharp 

加载网络图片 

//加载网络图片
Glide.With(this).Load("https://www.cnblogs.com/images/logo_small.gif").Into(ivPhoto);

 

接口请求

 项目源代码地址  https://gitee.com/freexiaoyu/xamarinDemo  代码压缩包下载

posted on 2018-12-06 16:51  freexiaoyu  阅读(1116)  评论(0编辑  收藏  举报