1

findViewById在 C++中调用的代码是什么?IDC++中的类型是什么?字符串、整数、指针?GetMethodID 的签名是什么?

string ID = "sample id";
jFindViewById = (env)->GetMethodID(cls, "findViewById", "ILjava/lang/Id;)Ljava/lang/Object;");
jobject myView = (jobject) (env)->CallObjectMethod(Obj, jFindViewById, ID);
4

1 回答 1

0

我自己刚刚找到了答案,虽然不是很明显,但经过一小时的反复试验后我得到了答案。希望它对其他人有帮助。

your jni funcion declaration... (JNIEnv* env, jobject Obj) {
   jmethodID jfindViewById = 0;
   int ID = 2; //get the ID somewhere else, it is just an integer.
   jfindViewById = (env)->GetMethodID(cls, "findViewById", "(I)Landroid/view/View;");
   jobject image_view = (jobject) (env)->CallObjectMethod(Obj, jfindViewById, ID);
}
于 2013-03-19T08:54:30.080 回答