I my case: I want to override a hide method in TextView
by extends TextView
, and make call to its super method.
public class MyTextView extends TextView {
protected void makeNewLayout(int wantWidth, int hintWidth,
BoringLayout.Metrics boring,
BoringLayout.Metrics hintBoring,
int ellipsisWidth, boolean bringIntoView) {
// omit try catch for simple
Method method = Class.forName("android.widget.TextView").getDeclaredMethod("makeNewLayout", int.class, int.class, BoringLayout.Metrics.class, BoringLayout.Metrics.class, int.class, boolean.class);
method.setAccessible(true);
method.invoke(this, wantWidth, hintWidth, boring, hintBoring, ellipsisWidth, bringIntoView);
}
}
The problem is my self define makeNewLayout
is called and the method.invoke is executed, but the method invoke is MyTextView::makeNewLayout
not TextView::makeNewLayout
, it a dead recursive call.
How can I acheive it?
PS: makeNewLayout is a hide function, so I cannot call it directly by super.makeNewLayout(...)
Aucun commentaire:
Enregistrer un commentaire