Search code examples
javaandroidoopinheritanceandroid-custom-view

Difference between CustomTextView as Parent and Textview as Parent


i created CustomTextview as below

public class CustomTextView extends AppCompatTextView {
        public CustomTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
       // im changing font family here .ttf files
    }
}

.

<com.android.app.CustomTextView
android:id="@+id/view”
/>

what is the difference between

This

CustomTextView textView = findViewbyId(R.id.view);

and this

TextView textView = findViewbyId(R.id.view);

When i put this TextView textView = findViewbyId(R.id.view); IDE runs without throwing error. Why? Thanks!


Solution

  • A real life comparison:

    When you learn to drive a manual transmission car, you can drive almost any manual transmission car. Imagine how bad it would be if you had to learn to drive every different model of car you encounter.

    Source (+)