可见性转换MvvmCross Android的关联问题 [英] MvvmCross Android Linking Issue on Visibility Converter

查看:319
本文介绍了可见性转换MvvmCross Android的关联问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有与Android链接问题,我知道如何使用LinkerPleaseInclude。但是我不知道该怎么投入为我看到的问题LinkerPleaseInclude.cs文件。

I know there are linking issues with Android and I know about using the LinkerPleaseInclude. However I am not sure what to put into the LinkerPleaseInclude.cs file for the problem I am seeing.

我有一个使用的可视性转换器中使用布尔IsBusy属性,以确定是否应该显示与否的一些控件的视图。我使用的进度,一个TextView和ImageView的。我已经尝试了多种组合,以获得链接问题解决。

I have a view which uses the Visibility converter to use a boolean IsBusy property to determine whether a number of controls should be displayed or not . I am using a ProgressBar, a TextView and an ImageView. I have tried a number of combinations to get the linker issue fixed.

在部署调试这一切的作品,它只是一个释放的问题。

When deployed as debug it all works, it is just a release issue.

因此​​,例如,我的进度被定义如下(该能见度转换器所使用的相同的方式对其他控制)

So for example my progressBar is defined as follows (The Visibility converter is used the same way for the other controls)

<ProgressBar
        android:id="@+id/pbHeaderProgress"
        style="?android:attr/progressBarStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:layout_centerInParent="true"
        local:MvxBind="Visibility Visibility(IsBusy)" />

我添加了以下我LinkerPleaseInclude.cs。我还没有为简洁整个文件

I have added the following to my LinkerPleaseInclude.cs. I have not included the whole file for brevity

    public void Include(ProgressBar progressBar)
    {
        progressBar.Visibility = ViewStates.Invisible;
    }

    public void Include(TextView textView)
    {
        textView.TextChanged += (sender, args) => textView.Text = "" + textView.Text;
        textView.Hint = "" + textView.Hint; 
        textView.Visibility = ViewStates.Invisible;
    }

    public void Include(ImageView imageView)
    {
        imageView.Visibility = ViewStates.Invisible;
        imageView.Visibility = ViewStates.Visible;
        imageView.Visibility = ViewStates.Gone;
    }

    public void Include(MyViewModel viewModel)
    {
        viewModel.PropertyChanged += (sender, args) => { };
    }

    public void Include(MvxVisibilityValueConverter converter)
    {
        converter.Convert(null, null, null, null);
    }

这些都不似乎工作。有人可以帮我这个,让我知道我应该把什么获得可见性的工作。

None of these seem to work. CAn someone help me with this and let me know what I should put in to get the Visibility to work

推荐答案

但问题是,构建一个Android应用程序的发行版时,有时会发现一些行为不起作用。这是由于它链接程序的方式。我认为它的方式,消除code,它认为它不使用优化。要修复它在基于MvvmCross程序,你必须添加到code,你认为它优化掉了电话。这是通过使用LinkerPleaseInclude.cs文件并添加到丢失code的呼叫完成。在对进度控制这种情况下,能见度不工作。我曾尝试添加code到LinkerPleaseInclude.cs文件,但它不工作。我找到了解决办法,并添加作为一个答案。

The problem was that when building a release version of an Android application you sometimes find that some of the behaviour does not work. This is due to the way it links the program. I believed it optimises in a way that removes code that it thinks it is not using. To fix it in an MvvmCross based app you have to add the calls to the code that you think it has optimised away. This is done by using the LinkerPleaseInclude.cs file and adding calls to the "missing" code. In this case visibility on a ProgressBar control was not working. I had tried adding code to the LinkerPleaseInclude.cs file but it was not working. I found the solution and added as an answer.

我把下面的code到LinkerPleaseInclude.cs。我觉得它的工作原理,因为它同时使用setter和getter

I put the following code into the LinkerPleaseInclude.cs. I think it works because it uses both the setter and getter

public void Include(ProgressBar ProgressBar)
{
   progressBar.Visibility = !progressBar.Visibility;
}

这篇关于可见性转换MvvmCross Android的关联问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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