Overridden Class Only Offers Static Methods
I have a class that overrides TextView however if I try to use any of the member functions of either my class or TextView I get an error message in Eclipse stating "Cannot make a static reference to the non-static method ##MEMBER FUNCTION## from the type View". Where ##MEMBER FUNCTION## is the method I am calling i.e. setLayoutParams(ViewGroup.LayoutParams). If I look in the suggestions dialog 开发者_开发知识库only the static methods are offered.
I have tried cutting my class down too;
import android.widget.TextView;
public class MyClass extends TextView {
public MyClass(Context context) {
super(context);
}
}
But I still get the same errors.
Thanks in advance,
Markyou're doing something like TextView.method() calls instead of textView.method() where textView is an instance of TextView. the error does not match your post title at all -- it's the opposite.
Make sure you're not calling the method with TextView.* in front.
For example, not:
TextView.getWidth();
but instead, simply:
getWidth();
精彩评论