C# 对Xamarin表单Android特定代码项目进行单元测试
我遇到了一个问题,我做了一个Xamarin.Forms应用程序 目前,我正在尝试对Android服务进行单元测试 所以现在这意味着我已经做了以下几点:C# 对Xamarin表单Android特定代码项目进行单元测试,c#,unit-testing,xamarin.android,xamarin.forms,C#,Unit Testing,Xamarin.android,Xamarin.forms,我遇到了一个问题,我做了一个Xamarin.Forms应用程序 目前,我正在尝试对Android服务进行单元测试 所以现在这意味着我已经做了以下几点: 删除iOS项目的默认Xamarin表单应用程序 创建PCL中的基本表单 在Xamarin.Forms PCL中创建样式 在Xamarin.Forms.Droid项目中具有基本主题 完成后,我创建了Xamarin UITest Android项目 现在,我添加了对Xamarin Forms.Droid项目的引用 每次我启动单元测试(必须在Andro
<Application.Resources>
<!-- Application resource dictionary -->
<ResourceDictionary>
<Color x:Key="BackgroundGlobal">#ff333333</Color>
<Color x:Key="MidGradient">#ff0d0d0d</Color>
<Color x:Key="BottomGradient">Black</Color>
<Color x:Key="MenuTextColor">Azure</Color>
<Style TargetType="ImageCell" x:Key="Clicky">
<Setter Property="TextColor" Value="{StaticResource MenuTextColor}"/>
<Setter Property="DetailColor" Value="Aqua"/>
</Style>
</ResourceDictionary>
</Application.Resources>
找不到与给定名称匹配的资源(位于'theme'处,值为'@style/MainTheme')
Resource\Values\strings.xml
只是为应用程序提供了一个文本字符串,其中包含可选的文本样式和格式。有三种类型的资源可以为您的应用程序提供字符串:字符串
、字符串数组
和数量字符串(复数)
您应该将主题样式放在Resource\Values\styles.xml
中,而不是像这样的styles.xml
有关
样式资源的详细信息,请阅读。styles.xml中是否存在主主题?您可以在Resource->values->styles.xml中看到它。根据请求,我已经更新了显示Xamarin.Forms.Droid中pcl样式和字符串/主题的示例。此外,测试项目是默认设置,带有Xamarin.Forms.Android和测试项目的资源/依赖项。谢谢您的回答。我昨天没能像我想的那样快地做出反应,因为我最终还是放弃了。无论如何@style/main主题
太完美了!在看了我写的东西之后,我发现,我确实在style.xml中有东西,而不是strings.xml。不管是哪种情况,我决定把我的问题留给其他可能也需要帮助的人。再次感谢您的帮助!
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MainTheme" parent="MainTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette-->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#2196F3</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#1976D2</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#FF4081</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#FF4081</item>
</style>
</resources>
Severity Code Description Project File Line Suppression State Error
Error: No resource found that matches the given name (at 'theme' with value '@style/MainTheme'). Xamarin.Forms.Droid.Tests C:\dev\git\example\Xamarin.Forms.Droid.Tests\obj\Debug\android\manifest\AndroidManifest.xml 9