lundi 10 septembre 2018

Use getDeclaredMethod using a function as a parameterType

I have a private method which header is:

private fun setNumericListener(editText: EditText, onValueChanged:(newValue: Double?) -> Unit)

I call this method in this way: setNumericListener(amountEditText, this::onAmountChanged)

I would like to use getDeclaredMethod from Class https://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getDeclaredMethod(java.lang.String,%20java.lang.Class...) to get a reference to my private method setNumericListener. getDeclaredMethodreceives an array of parameter types Class<?>... parameterTypes but I have no idea about how to set the parameter types array when my private method has a method reference as a parameter.

Thanks





Aucun commentaire:

Enregistrer un commentaire