Looks like an inner static java class, but apparently not (I don't understand how this is possible?)

From: http://developer.android.com/resources/tutorials/views/hello-gridview.html , in ImageAdapter class:

imageView.setLayoutParams(new GridView.LayoutParams(85, 85));

      

Take a look at the new GridView.LayoutParams part . LayoutParams seems to be the internal static class of the GridView class, but according to the android docs, the full path of the GridView class is android.widget.GridView and LayoutParams is android.widget.AbsListView.LayoutParams . Therefore LayoutParams is not an internal static class of the GridView.

How is this possible?

References:
GridView class from android doc LayoutParams class from android doc

+3


source to share


3 answers


AbsListView is the base class of the GridView



+4


source


Presumably like this:

class BaseOuter {
   static class BaseInner {
   }
}

class SubOuter extends BaseOuter {
}

public class Test {
    public static void main(String[] args) {
        SubOuter.BaseInner x = new SubOuter.BaseInner();
    }
}

      



I would suggest using the "canonical" way of referring to a nested type instead (as BaseOuter.BaseInner

in my example) just for clarity.

+7


source


Just like @Jon Skeet suggested, LayoutParams

is an inner static class AbsListView

and GridView

extends AbsListView

thus inherits the inner class.

You can look at the source code on GitHub to see exactly:

+1


source







All Articles