【发布时间】:2017-06-27 22:52:33
【问题描述】:
我有一个只能在调试模式下工作的转换器。当我生成 Release .apk 时,它不再起作用了。
这是我的代码:
public class CardapioImageColorConverter : MvxValueConverter<bool, ColorStateList>
{
private static Activity Activity => Mvx.Resolve<IMvxAndroidCurrentTopActivity>().Activity;
protected override ColorStateList Convert(bool value, Type targetType, object parameter, CultureInfo culture)
{
ColorStateList color;
if (value)
color = Activity.Resources.GetColorStateList(Resource.Color.cor1,Activity.Theme);
else
color = Activity.Resources.GetColorStateList(Resource.Color.white, Activity.Theme);
return color;
}
}
还有我的 axml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="70dp"
android:layout_height="70dp">
<Mvx.MvxImageView
android:id="@+id/imageView"
android:layout_weight="1"
android:tint="@color/white"
android:layout_width="match_parent"
android:layout_height="match_parent"
local:MvxBind="ImageUrl Icone;ImageTintList CardapioImageColor(Selecionado);"
android:layout_gravity="center" />
<TextView
local:MvxBind="Text Nome; TextColor CardapioTextColor(Selecionado);"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@color/cor1"
android:textSize="11dp"
android:layout_weight="1.9"
android:text="@string/lista_espera"
android:gravity="center"
android:layout_marginBottom="@dimen/margin_tiny"
android:layout_marginTop="@dimen/margin_tiny" />
</LinearLayout>
它在调试模式下完美运行。你知道为什么会这样吗?
【问题讨论】:
-
您是否在为
Mvx.MvxImageView使用任何第三方库? -
在调试模式下尝试启用链接器,你会得到任何错误吗?
-
我只使用 sdk 程序集,两种情况。调试和发布。
-
我使用来自 Mvvmcross.Platform 的原生 Mvx.MvxImageView
-
我已尝试将此代码跳过链接程序集,但仍然无法正常工作。 MvvmCross.Binding;MvvmCross.Core;MvvmCross.Plugins;MvvmCross.Platform;MvvmCross.Plugins.DownloadCache;MvvmCross.Plugins.DownloadCache.Droid;MvvmCross.Plugins.File;MvvmCross.Plugins.File.Droid;MvvmCross.Plugins.Json; MvvmCross.Plugins.Json.Droid;MvvmCross.Plugins.Visibility;MvvmCross.Plugins.Visibility.Droid;Refit;RefitInternalGenerated;
标签: android xamarin xamarin.android mvvmcross