代码之家  ›  专栏  ›  技术社区  ›  KellyTheDev

单元测试Xamarin表单Android特定代码项目

  •  0
  • KellyTheDev  · 技术社区  · 9 年前

    我遇到了一个问题,我做了一个Xamarin。表格申请。

    目前这意味着我已经做了以下几点:

    1. 创建的PCL中的基本表单

    之后,我创建了Xamarin UITest Android项目

    现在,我添加了对Xamarin表单的引用。Droid项目

    在应用程序内。驻留在PCL中的xml

    <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>
    

    在Xamarin.Forms中。Droid资源\值\字符串.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   
    
    1 回复  |  直到 9 年前
        1
  •  1
  •   York Shen    9 年前

    未找到与给定名称匹配的资源(在“theme”处,值为“@style/MainTheme”)。

    Resource\Values\strings.xml String , String Array Quantity Strings(Plurals) .

    你应该把你的主题风格 Resource\Values\styles.xml 而不是 styles.xml 喜欢 this

    Style Resource ,你可以读这个 document .