On Wednesday, July 4, 2012 2:29:56 AM UTC-7, Alex Belyaev wrote:
>
> I have encountered several issues while extending ListView widget. 
> According to the sources, we have the following inheritance chain: 
>
> CustomListView<-ListView<-AbsListView<-ViewGroup...
>
> I'm trying to override layoutChildren() method and here comes the first 
> issue. After calling super.layoutChildren() program execution comes to 
> the point, where obtainView() method of the 
> AbsListView.java<http://grepcode.com/file_/repository.grepcode.com/java/ext/com.google.android/android/2.3.7_r1/android/widget/AbsListView.java/?v=source>abstract
>  class should be called from 
> ListView.java<http://grepcode.com/file_/repository.grepcode.com/java/ext/com.google.android/android/4.0.3_r1/android/widget/ListView.java/?v=source>class.
>  
> obtainView() method has default access modifier, as a result, I should 
> not have an ability to override it in my CustomListView class, since 
> AbsListView belongs to the different package. But, if I place 
> obtainView()method in 
> CustomListView class, it works!  So my first question is, why does this 
> happen? 
>
I think you are mistaken in your understanding of what happens when you 
define obtainView in the subclass.  You, absolutely can create a method 
with that name.  The new method does not override the the base class 
method, it hides it.
The base class method is not visible from the subclass: super.obtainView is 
a compile error from the new class.  Using the @Override tag will help 
identify problems like this.
 

> The second question is very similar to the first one. We have two methods (
> attachViewToParent() and addViewInLayout()) in the ViewGroup class. Both 
> of them have protected access modifier, thus, it is possible to override 
> them. But if I place this methods in CustomListView class, this doesn't 
> work for me.
>
> So the question is, why?
>
This one I don't understand.  That seems like it should work.  Can you give 
more details.

G. Blake Meike
Marakana

The second edition of Programming Android is now on-line:
http://shop.oreilly.com/product/0636920023005.do
 

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to