gpt4 book ai didi

android - 在 ObjectAnimator 中指定 propertyName 时找不到使用 JNI 错误的 native 方法

转载 作者:行者123 更新时间:2023-11-30 02:23:15 25 4
gpt4 key购买 nike

我正在尝试制作滑动 fragment ,如以下代码所示:https://github.com/lucamtudor/Sliding-Fragments

但是,当移植到 Xamarin 时,它给出了错误:

01-26 18:07:10.943 D/PropertyValuesHolder(17296): Can't find native method using JNI, use reflectionjava.lang.NoSuchMethodError: no method with name='setYFraction' signature='(F)V' in class Ltestappandroid/FractionalLinearLayout;
01-26 18:07:10.943 E/PropertyValuesHolder(17296): Couldn't find setter/getter for property yFraction with value type float

自定义动画如下所示:

<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:valueFrom="0"
android:valueTo="@dimen/slide_up_down_fraction"
android:propertyName="yFraction"
android:valueType="floatType"
android:duration="@integer/slide_up_down_duration">
</objectAnimator>

在我的 FractionalLinearLayout 中我有:

public float getYFraction()
{
return mYFraction;
}

public void setYFraction(float yFraction)
{
mYFraction = yFraction;
SetY((mScreenHeight > 0) ? (mScreenHeight - yFraction * mScreenHeight) : 0);
}

当然,我还添加了一个首字母大写的副本,以及首字母大写和非大写的 C# 属性,但它不起作用(同样的错误)。

尝试使用 Xamarin 从 xml 引用方法时是否有任何问题?完整代码可在此处获得:http://home.harteex.com/TestAppAndroid.zip

最后,我也看到了这个,不知道它是否相关:

01-26 18:07:10.853 I/dalvikvm(17296): Could not find method android.widget.LinearLayout.<init>, referenced from method testappandroid.FractionalLinearLayout.<init>
01-26 18:07:10.853 W/dalvikvm(17296): VFY: unable to resolve direct method 233: Landroid/widget/LinearLayout;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;II)V
01-26 18:07:10.853 D/dalvikvm(17296): VFY: replacing opcode 0x70 at 0x0000

最佳答案

您需要向您的 getter 和 setter 添加一个 [Export] 属性。

[Export]
public float getYFraction()
{
return mYFraction;
}

[Export]
public void setYFraction(float yFraction)
{
mYFraction = yFraction;
SetY((mScreenHeight > 0) ? (mScreenHeight - yFraction * mScreenHeight) : 0);
}

参见:ObjectAnimator Proxy to Animate TopMargin can't find setting/getter

关于android - 在 ObjectAnimator 中指定 propertyName 时找不到使用 JNI 错误的 native 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28167510/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com