Saw the exiting question, but the accepted answer with 22 votes does not seem to compile. The answer is
val hello = Hello()
val f = Hello::class.memberProperties.find { it.name == "world" }
f?.let {
it.isAccessible = true
val w = it.get(hello) as World
println(w.foo())
}
, but class
has no memberProperties
. The closest thing I could find is members
, but it seems that it does not return the correct type. How can I get the private field "mEditor"?
val f = TextView::class.members.find {it.name == "mEditor"};
f?.let{
it.isAccessible=true;
val w = it.get(text2)
}
Unresolved reference: isAccessible
TextView.java
@RemoteView
public class TextView extends View implements ViewTreeObserver.OnPreDrawListener {
....
/**
* {@link EditText} specific data, created on demand when one of the Editor fields is used.
* See {@link #createEditorIfNeeded()}.
*/
@UnsupportedAppUsage
private Editor mEditor;
Aucun commentaire:
Enregistrer un commentaire