My question is about Java/Android.
How can I call a non-static method from an constructor?
My code:
public class input extends TextView{
public input(Context context, AttributeSet attr) {
super(context, attr, getIdentifier()); //Error
}
public int getIdentifier(){
if(getInputType() == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS){
return Resources.getSystem().getIdentifier("editTextStyle","attr","android");
}
else{
return Resources.getSystem().getIdentifier("textViewStyle","attr","android");
}
}
}
I read all stackoverflow questions related to my question but no one helps me because they offer only two solution: Create a new instance or set the method to call to static
In this case, I can't create a new instance, because the app would crash:
super(context, attr, new input(context,attr).getIdentifier());//App crashes
And in my case, I can't set my getIdentifier method to static because then I can't call inside the getInputType method, as you can see...
So how can I solve my problem?