小编Flo*_*ian的帖子

应用程序中的JNI DETECTED ERROR:无法在null对象上调用void android.view.View.setTranslationZ(float)

我有一个复杂的应用程序,当点击按钮触发两个视图通过FadeIn-和TranslateX动画出现时出现此错误.视图已在之前加载并且也已插入到布局中(作为不可见).在运行应用程序时,我点击按钮,出现错误.

这是堆栈跟踪:

11-07 10:42:08.986 F/art     (29902): sart/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: can't call void android.view.View.setTranslationZ(float) on null object
11-07 10:42:08.986 F/art     (29902): sart/runtime/check_jni.cc:65]     in call to CallVoidMethodV
11-07 10:42:08.986 F/art     (29902): sart/runtime/check_jni.cc:65]     from void android.animation.PropertyValuesHolder.nCallFloatMethod(java.lang.Object, long, float)
11-07 10:42:08.986 F/art     (29902): sart/runtime/check_jni.cc:65] "main" prio=5 tid=1 Runnable
11-07 10:42:08.986 F/art     (29902): sart/runtime/check_jni.cc:65]   | group="main" sCount=0 dsCount=0 obj=0x87394ef0 self=0xb4e08000
11-07 10:42:08.986 F/art     (29902): sart/runtime/check_jni.cc:65]   | sysTid=29902 nice=0 cgrp=apps sched=0/0 handle=0xb6f18ec8
11-07 10:42:08.986 F/art     (29902): sart/runtime/check_jni.cc:65]   | state=R schedstat=( 12655665356 2452371955 8477 …
Run Code Online (Sandbox Code Playgroud)

animation android xamarin xamarin.forms

5
推荐指数
0
解决办法
1091
查看次数

使用 SSL 的 Xamarin.Forms Image.Source

我正在使用一个在线商店来存储通过我们的应用程序上传的用户图像,并受 SSL 保护。上传工作一切顺利,因为我使用的是带有附加证书的 WebClient。但是,当我尝试使用 Xamarin.Forms.Image 组件(例如,源设置为“ https://blabla.com/upload/image123.jpg ”)时,图像无法在 Android 上加载。在 iOS 上,这是有效的,因为我有一个自定义的 NSUrlProtocol 来处理 SSL 连接。

var image = new Image();

//will use ImageLoaderSourceHandler 
image.Source = "https://blabla.com/upload/image123.jpg";
Run Code Online (Sandbox Code Playgroud)

对于 WebClient,我将 X509Certificate2(私钥和密码)附加到 HttpWebRequest.ClientCertificates 并且它可以工作。但我不知道如何向 ImageLoaderSourceHandler 背后的任何加载机制提供该证书。

我如何才能在 Android 上实现此功能?

ssl image imagesource xamarin xamarin.forms

5
推荐指数
1
解决办法
4093
查看次数

ContentView 的自定义渲染器 (iOS)

我有以下几点

public class ViewBase : ContentView
{
    //...
}
Run Code Online (Sandbox Code Playgroud)

当我在 XAML 中使用它时

<local:ViewBase xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    xmlns:local="clr-namespace:MyForms;"
    x:Class="MyForms.Finder" 
    BackgroundColor="Color.Yellow">

    <!-- ... -->

</local:ViewBase>
Run Code Online (Sandbox Code Playgroud)

当我为此使用 CustomRenderer 并且甚至(如下所示)在其中什么都不做时,上面的 BackgroundColor 没有设置。当我没有定义以下几行时,背景是预期的黄色。

[assembly: ExportRenderer(typeof(ViewBase), typeof(ViewRendererBase))]
namespace MyiOS
{    
    public class ViewRendererBase : ViewRenderer
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

BackgroundColor 是 ViewRenderer 的一个属性。我查看了代码,似乎 Control 没有设置(我不调用 SetNativeControl)它不能将 Control.BackgroundColor 设置为一个值。但为什么会发生这种情况?我的猜测是 ViewRenderer 的继承有问题,因为默认行为在 ContentView 上使用了不同的东西!?

background ios xamarin xamarin.forms

3
推荐指数
1
解决办法
2886
查看次数

动态显示/隐藏Xamarin.Forms.ListView的页眉或页脚

有没有办法根据运行时的条件动态显示/隐藏ListView的标头.

<ListView x:Name="ListViewChallenges" Header="{Binding .}">

    <ListView.FooterTemplate>
        <DataTemplate>
            <Label Text="No Elements found." IsVisible="{Binding FooterIsVisible}" />
        </DataTemplate>
    </ListView.FooterTemplate>

    <!-- ... -->

</ListView>
Run Code Online (Sandbox Code Playgroud)

在BindingContext中,我声明了FooterIsVisible属性.当它是假的时,页脚应该是不可见的.但是这不起作用,页脚总是占用ListView底部的Label的一定空间.

这有点可能吗?

listview xamarin xamarin.forms

3
推荐指数
1
解决办法
5093
查看次数

Xamarin.Forms在ResourceDictionary控件中正确绑定方式

我在解决这个问题上遇到了问题.

<ResourceDictionary>
    <ViewCell x:Key="Separator">
        <Label Text="{Binding Title}" />
    </ViewCell>
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)

类Option包含名为Title的属性,该属性设置为任何文本.但是,以下代码无效.标签中不显示任何文字.文本只是保持"null".我做错了什么 - 我怎样才能正确设置Binding?

if (Resources.ContainsKey("Separator"))
{
    var cell = Resources["Separator"] as Cell;

    if (cell != null)
    {
        cell.BindingContext = option;

        section.Add(cell);
    }
}
Run Code Online (Sandbox Code Playgroud)

xaml binding xamarin xamarin.forms

0
推荐指数
1
解决办法
458
查看次数