在扩展Android组件时无法使用JNI找到本机方法

时间:2014-01-20 09:48:48

标签: java android java-native-interface

我有一个课程来扩展NumberPicker组件来介绍min&最大值:

public class ExtendedNumberPicker extends NumberPicker {
    public ExtendedNumberPicker(Context context) {
        super(context);
    }

    public ExtendedNumberPicker(Context context, AttributeSet attrs) {
        super(context, attrs);
        processAttributeSet(attrs);
    }

    public ExtendedNumberPicker(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        processAttributeSet(attrs);
    }
    private void processAttributeSet(AttributeSet attrs) {
        //This method reads the parameters given in the xml file and sets the properties according to it
        this.setMinValue(attrs.getAttributeIntValue(null, "min", 0));
        this.setMaxValue(attrs.getAttributeIntValue(null, "max", 0));
    }
}

我把它放到布局中:

<com.example.myapp.component.ExtendedNumberPicker
        android:id="@+id/pick_hh"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView1"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="16dp"
        min="140"
        max="200" />

在LogCat中,它显示:

Tag                    Text
---------------------------
PropertyValuesHolder   Can't find native method using JNI, use reflectionjava.lang.NoSuchMethodError: no method with name='setSelectorPaintAlpha' signature='(I)V' in class Lcom/example/myapp/component/ExtendedNumberPicker;
PropertyValuesHolder   Couldn't find setter/getter for property selectorPaintAlpha with value type int

我知道JNI是Java Native Interface,但我从不使用/查看属性selectorPaintAlpha。它是什么?如何解决这个问题?

0 个答案:

没有答案