1. Download our Official Android App: Forums for Android!

about typecasting in android source

Discussion in 'Android Lounge' started by proandceo, Jul 5, 2010.

  1. proandceo

    proandceo Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Jul 5, 2010

    Jul 5, 2010
    1
    0
    5
    Dear Sir,

    as you know, we can see "CalculatorDisplay.java" in git.

    if you open the file, you can see line 59, 60(calc.adjustFontSize((TextView)getChildAt(0));)

    in here, I have a question.

    I searched for getChildAt, which it is in ViewGroup class.
    both android.widget.ViewGroup and android.view.TextView are sibling
    and two class received inheritance from android.view.View
    in addition, until now, I know that it is possible that typecasting is inheritance relative.

    so I can not understand why (TextView)getChildAt(0) is Ok??

    if someone know this reason, can you explain for me?
     

    Advertisement

Share This Page

Loading...