簡體   English   中英

CustomTextView 作為父級和 Textview 作為父級之間的區別

[英]Difference between CustomTextView as Parent and Textview as Parent

我創建了 CustomTextview 如下

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”
/>

有什么區別

這個

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

和這個

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

當我把這個TextView textView = findViewbyId(R.id.view); IDE 運行時沒有拋出錯誤。 為什么? 謝謝!

現實生活中的比較:

當您學會駕駛手動檔汽車時,您幾乎可以駕駛任何手動檔汽車。 想象一下,如果你必須學會駕駛你遇到的每輛不同的 model 的汽車,那該有多糟糕。

來源(+)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM