Why cant I inherit a protected field from android.view?
I'm trying to override the offsetTopAndBottom(int offset) method which is a View class method.
But when I try to access the mTop or mBottom fields, even though they are protected in the View class, I get an error.
Does anyone know why I would have this kind of access problem ?
For example:
Cus开发者_如何学CtomView extend android.view.View{
someOverridenMethod()
{
mTop = 10 //error, mTop no resolved as a type
}
}
All m{variables} are not accessible. For the life of me I can't remember why, something to do with m{variables} not being part of the public API.
I had a similar problem and after days of searching, I pretty much found it to be impossible.
I believe you can try calling View.layout(int left, int top, int right, int bottom);
this will ultimately set the mTop value, at which point you can call getTop(). However there is a method to the madness and you will find that a number of other methods will be called as a result. So whether this actually helps you or not is well...to be seen.
According to the View javadoc there is no member or method called mTop.
加载中,请稍侯......
精彩评论