JNI: 能否用 GetFieldID()/GetStaticFieldID()取得enum变量的属性?

没有问题的,jni下面一样可以动态获取的

仅供参考!
VOID CVMAndroidDC::SetStyle()
{
static jmethodID jmidSetStyle=NULL;
if(jmidSetStyle==NULL)
{
jclass jclsPaint=m_pJNIEnv->FindClass("android/graphics/Paint");
jmidSetStyle=m_pJNIEnv->GetMethodID(jclsPaint,"setStyle","(Landroid/graphics/Paint$Style;)V");
}
jclass jclsStyle=m_pJNIEnv->FindClass("android/graphics/Paint$Style");
jfieldID jfidStyle=m_pJNIEnv->GetStaticFieldID(jclsStyle, "STROKE", "Landroid/graphics/Paint$Style;");
jobject style=m_pJNIEnv->GetStaticObjectField(jclsStyle, jfidStyle);

m_pJNIEnv->CallVoidMethod(m_jobjPaint,jmidSetStyle,style);
}

你可能感兴趣的:(JNI: 能否用 GetFieldID()/GetStaticFieldID()取得enum变量的属性?)