Xamarin表单按钮中的Android资源名称 [英] Android Resource Name From Xamarin Forms Button

查看:110
本文介绍了Xamarin表单按钮中的Android资源名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,您可以在Play商店中为发布前报告模拟器指定凭据以供使用.为了使仿真器知道要将凭据添加到哪个文本字段以及单击哪个按钮来登录,它要求文本字段和按钮的资源名称.

Xamarin表单的任何属性都可以转换为资源名称吗?构建应用程序后,我尝试在/obj//bin/文件夹中查找,以查看其中一个文件是否具有类似内容,但找不到任何内容./p>

我可以想到的可能的属性可能映射到资源名称:

StyleId
AutomationId
ClassId
AutomationProperties.Name (in XF 2.3.5)

如果没有任何映射,您是否知道使用自定义渲染器进行这项工作的方法?

解决方案

您可以使用两个选项将发布前的报告与Xamarin.Forms一起使用:

1)通过包含用户名&密码Entry字段,登录按钮是可选的,如果未提供,则机器人将点击屏幕上的每个可用按钮.

您可以将此Activity定义为您的主启动器(或在启动画面"活动之后启动的活动),并独立于Xamarin.Forms代码执行登录身份验证,当然您可以访问PCL/NStd库代码.身份验证成功后,继续执行"MainActivity",该操作将执行常规的Xamarin.Forms初始化,或通过自定义渲染器(或最容易完成完整Activity的依赖项服务)呈现此登录活动(或ViewGroup,Fragment等). ....)

现在,您知道了Google所需的资源ID,因为它们在登录布局XML中被硬编码了.

2)作为 Alpha/Beta 发布您的应用,并使其自动登录到测试帐户,或者仅显示预先提供的登录屏幕测试帐户用户和密码已填写,并将这些条目设置为只读.机器人将点击登录按钮.

选项2是最快,最容易设置的,因为您已经拥有一个登录页面,只需要将这两个字段的测试帐户ID/密码定义为默认值,然后将这些字段设置为只读....

The Play Store now allows you to specify credentials for the Pre-launch Report emulator to use. In order for the emulators to know which text field to add the credentials to and which button to click to login, it asks for the text field and button's Resource Name.

Do any of the Xamarin Form's properties translate into a Resource name? I tried looking in the /obj/ and /bin/ folders after building my app to see if one of the files had anything like this but I did not find anything.

Possible properties that I can think of that might map to a Resource Name:

StyleId
AutomationId
ClassId
AutomationProperties.Name (in XF 2.3.5)

If nothing maps over, would you know of a way to use a custom renderer to make this work?

解决方案

You have two options to use the Pre-launch reports with Xamarin.Forms:

1) Define a Login Activity via a Layout XML resource that includes a username & password Entry fields, a login button is optional and if not supplied, the robots will tap every available button on the screen.

You can either define this Activity as your main launcher (or the activity that gets launched after "splash screen" activity) and perform the login authentication independently of Xamarin.Forms code, of course you can access PCL/NStd library code. After authentication success, proceed to the "MainActivity" which does the normal Xamarin.Forms initiation or present this Login Activity (or ViewGroup, Fragment, ...) via a custom renderer (or a dependency service which is the easiest for a complete Activity....)

Now you know the resource ids that Google needs as they are hardcoded in the Login layout XML...

2) Publish your app as an Alpha/Beta and either have it auto-login to a test account or just present a login screen that have a pre-supplied test account user and pwd filled in and have those entries set to read-only. The robot will tap the login button.

Option 2 is the quickest and easiest to setup as you would already have a login Page and just need to define a test account id/pwd to those two fields as defaults and then set those fields to read-only....

这篇关于Xamarin表单按钮中的Android资源名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆