【c# – Xamarin(Android)Visual Studio 2017中的单元测试】教程文章相关的互联网学习教程文章

c# – 如何设置背景图像Xamarin Android【代码】

我想在后台项目Xamarin Android中放一个简单的图像…在我的项目中,我可以看到图像,但我建立的,不要在我的应用程序中显示.. 如你所见,我的背景图片调用hue.jpg,这是我的XML文件..<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:minWidth="25p...

c# – Xamarin.Forms属性未保存在Android版本中

我正在使用Xamarin.Forms和Application.Current.Properties来持久保存用户设置.我在Android上测试它,它工作正常 >在调试模式下>在发布模式下,链接器配置设置为无 但它不适用于仅设置为SDK Assemblies的链接器配置.我正在通过将APK文件直接部署到设备来进行测试.然后我尝试输入一些设置并重新启动应用程序 – 重启后所有设置都将丢失.我没有使用复杂的数据类型,只有字符串和bool. 我在这里找到了一个解决方法:https://forums.xamar...

java – Xamarin android映像URI到Byte数组【代码】

我只是想将图像上传到服务器. 当我选择图像时,我得到该图像的URI.问题是如何将此URI转换为byte []字节数组? 不多也不少.这就是我的问题 这就是我一直在尝试的. 我试着改写这个https://colinyeoh.wordpress.com/2012/05/18/android-convert-image-uri-to-byte-array/到C#public byte[] convertImageToByte(Android.Net.Uri uri){byte[] data = null;try{ContentResolver cr = this.ContentResolver;var inputStream = cr.OpenInput...

Xamarin Android 7以编程方式安装APK【代码】

我正在尝试安装我已经下载到Android 7中的下载文件夹的.apk. 我已经尝试过在许多StackOverflow帖子中推荐的方式,并使用FileProvider在这里https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en:File file = new File(fileUri); //using Android.Support.V4.Content; var downloadUri = FileProvider.GetUriForFile(context,context.ApplicationContext.PackageName + ".com....

c# – Android的不可用组件HockeyApp(Xamarin组件商店)【代码】

我试图将上面提到的组件投入使用. http://components.xamarin.com/view/hockeyappios 我创建了一个基于Xamarin Studio模板的非常简单的项目(Android Ice Cream Sandwich Application)然后我添加了向HockeyApp发送异常的必要代码.此代码在下一页中介绍 http://components.xamarin.com/gettingstarted/hockeyappandroid 不幸的是,我发现存储异常信息文件存在一个主要问题HockeyApp.ManagedExceptionHandler.SaveException (e.Excepti...

c# – Xamarin Android Alarm Manager问题【代码】

我的Xamarin Android应用程序中有一个AlarmManager.我正在使用SetExact()配置它,时间为5分钟.但它只在五秒后开始.无论我在什么时候配置它,它总是会在5秒后触发.我在Java中使用了完全相同的代码,它工作得很好. 代码:[BroadcastReceiver]public class AlarmReceiver : BroadcastReceiver{public override void OnReceive(Context context, Intent intent){Log.Info("AlarmReceiver", "Triggered");}public static void Start(Contex...

c# – Scrollview监听器在Xamarin for Android中无效?【代码】

我在Xamarin中使用C#来创建一个Android应用程序.我创建了scrollview的扩展.这是我的代码public class EndlessScroll : ScrollView { public EndlessScroll (Context context) : base (context){}public EndlessScroll(Context context, IAttributeSet attrs) : base(context, attrs){}public EndlessScroll(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle){}public interface OnScrollView...

c# – Xamarin Android,从内部存储/下载中读取一个简单的文本文件【代码】

我正在使用Xamarin,根据之前的答案,这应该有效:string path = Path.Combine(Android.OS.Environment.DirectoryDownloads, "families.txt"); File.WriteAllText(path, "Write this text into a file!");但它没有,我得到和未处理的异常.我已设置读取和写入外部存储的权限(即使这是内部存储). 我也试过这个:string content; using (var streamReader = new StreamReader(@"file://" + path )) // with and without file:// {content...

c# – Xamarin – 删除Android中的SearchBar下划线【代码】

我试图在Android上的SearchBar控件下删除黑色下划线.我写了一个我认为会完成这个的CustomRender,但没有运气:[assembly: ExportRenderer(typeof(NoUnderlineSearchBar), typeof(NoUnderlineSearchBarRenderer))] namespace XamarinDemo.Droid.CustomRenderers {public class NoUnderlineSearchBarRenderer : SearchBarRenderer{protected override void OnElementChanged(ElementChangedEventArgs<SearchBar> e){base.OnElementCha...

c# – 使用xamarin表单删除Android上的顶栏【代码】

我试过几种解决方案,包括<item name="android:actionBarSize">0dp</item>要么var activity = (Activity)Forms.Context; this.Window.AddFlags(WindowManagerFlags.Fullscreen);要么RequestWindowFeature(WindowFeatures.NoTitle);或者在活动字符串中Theme = "@style/MainTheme.FullScreen"但我找不到任何有效的解决方案,或者更确切地说,删除了我的歌词,电池时间等,但我仍然保持相同的顶部栏,我怎么能完全删除它?在iOs上我添加了:...

c# – 如何从Xamarin Forms for Android中的按钮视图中删除额外的填充?【代码】

Xamarin Forms上的按钮视图似乎在部署到Android时会应用额外的填充.我在我的Android项目下设置了Resources / values / styles.xml,默认情况下所有间距,填充和边距都为0,但仍然应用了额外的填充:<item name="android:radius">0.0px</item> <item name="android:shadowRadius">0.0</item> <item name="android:spacing">0.0px</item> <item name="android:padding">0.0px</item> <item name="android:layout_margin">0.0px</item>请...

c# – Xamarin Android,自定义控件和Visual Studio设计器【代码】

我使用Visual Studio和C#在Xamarin中创建了一个自定义控件. Custom控件完美运行,代码非常简单:[DesignTimeVisible(true)] public class CustomTextView : TextView {public CustomTextView(Context context):base(context){}public CustomTextView(Context context, IAttributeSet attrs):base(context,attrs){}public CustomTextView(IntPtr javaReference, JniHandleOwnership transfer):base(javaReference, transfer){}public...

物理机调试Xamarin程序(Android)【图】

1、手机开启开发者模式 默认情况下,“开发人员选项”是隐藏的,可以搜索不同品牌手机开启开发者模式的方法(本文默认以小米手机为例) 在”设置“中点击“我的设备”->"全部参数"->连续点击“MIUI版本”,直到手机下方弹出“您已处于开发者模式”提示 2、开启USB调试 在”设置“中点击"更多设置"->找到"开发者选项"->开启”USB调试“ 3、电脑安装手机USB驱动 不同手机驱动程序不同,请自行搜索小米手机USB驱动下载地址下载完成后,...

c# – 将数据从服务发送到其他活动的BroadcastReceiver(Xamarin Android)【代码】

我将从服务位置发送到自定义BroadcastReceiver时遇到问题. 这是我的BroadcastReceiver.cs[BroadcastReceiver] class MyBroadcastReceiver : BroadcastReceiver {public static readonly string GRID_STARTED = "GRID_STARTED";public event EventHandler<OnLocationChangedEventArgs> mOnLocationChanged;private Location location;public override void OnReceive(Context context, Intent intent){if (intent.Action == GRID_ST...

C#-Xamarin的Android项目开发(一)——创建项目【图】

原文:C#-Xamarin的Android项目开发(一)——创建项目创建项目 使用Xamarin开发安卓项目,首先需要安装VS2017以上版本。因为VS2017以上的版本,可以直接创建Xamarin项目。 另外用Xamarin开发安卓项目,还需要使用Intel的CPU,并且得是双核以上的CPU,因为调试时,需要使用电脑的虚拟化,奔腾4之类的CPU是不支持虚拟化的。 下面我们创建KibaXamarin_Android项目,如下图:点击确定后,会弹出一个选择模板的窗体,这里我们选择一个空白...