Warm tip: This article is reproduced from serverfault.com, please click

Difference between CustomTextView as Parent and Textview as Parent

发布于 2020-12-16 13:00:45

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!

Questioner
user90874
Viewed
0
Mohammad Fazel 2020-12-16 21:11:36

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 (+)