【发布时间】:2018-01-17 09:17:16
【问题描述】:
我通过名为 Xamarin.GradleBinding 的 Visual Studio 扩展创建了 Java 绑定库。我添加了ru.rambler.android:swipe-layout:1.0.14 包,在使用它的SwipeLayout 时,一切正常。但不幸的是,它没有创建相应的 C# 类或类似的东西。我尝试手动添加包,但仍然没有。
我检查了source on GitHub。 SwipeLayout 有一个 public void 方法 reset() 没有参数:
public void reset()
我尝试使用 JNIEnv 从 c# 调用此方法。
IntPtr type = JNIEnv.FindClass("ru/rambler/libs/swipe_layout/SwipeLayout");
IntPtr method = JNIEnv.GetMethodID(type, "reset", "()V");
try
{
JNIEnv.CallObjectMethod(_swiper.Handle, method);
}
catch (Exception ex)
{
var s = ex.Message;
}
类型和方法已成功找到但正在调用
JNIEnv.CallObjectMethod(_swiper.Handle, method);
此方法使应用程序崩溃,甚至没有进入 catch 块。
Tt 必须是_swiper.Handle 第一个参数的原因。
_swiper 字段的类型为 ViewGroup,因为 SwipeLayout 派生自 ViewGroup。
我找不到如何获取视图指针以传递该方法。
在调试时,当我调查_swiper 时,它似乎是SwipeLayout 的正确实例
【问题讨论】:
-
我很确定 xamarin 中不存在构建 gradles
-
它有效,当我添加AXML文件时它显示自定义视图,但没有c#等效类
-
你要找什么课
-
@G.hakim SwipeLayout
-
它有什么作用?可能会有一个 xamarin android 等价物,为什么不使用它
标签: java xamarin xamarin.android jnienv java-binding