Re: [android-developers] ViewPager pages not drawn

2014-12-20 Thread Doug Gordon
Kostya, I have done that and what I am seeing is the background of the 
ViewPager, but not my fragments' views. I set a breakpoint so I could go 
back into the ViewPager, and examining its data structure I find that not 
only does its mItems array contain my instantiated fragments, but also the 
mChildren array in the base View contains my fragments' expanded view 
hierarchies!

There is just something that is preventing the views from being drawn, even 
if I explicitly call invalidate() on the ViewPager. And it still seems that 
it must have something to do with using the support.v4 fragment support 
since it all works fine using native fragments.

On Friday, December 19, 2014 4:57:43 PM UTC-5, Kostya Vasilyev wrote:
>
> Have you tried debugging into ViewPager code?
>
> To see if your fragments' views are actually there and how they're laid 
> out?
>
> Another thing I often use in cases like this -- is to set the background 
> color of various views to distinct noticeable colors, like pink, cyan, etc. 
> In this case, I'd try the view pager itself, its parent view, and your 
> fragments' views.
>
> -- K
>
> 2014-12-20 0:30 GMT+03:00 Doug Gordon >:
>
>> I haven't received any responses on stackoverflow about this, so am 
>> giving it a shot here.
>>
>> My app, which is fairly large and complex (hard to post meaningful code) 
>> uses as its main view a ViewPager with a FragmentPagerAdapter. Since the 
>> minSDK is 14, I originally wrote it to use the native Fragment and related 
>> classes (ViewPager from support.v4 and FragmentPagerAdapter from 
>> support.v13). This has all been working perfectly for a long time.
>>
>> Recently I decided to build in more compatibility, mainly for themes, by 
>> using the appcompat.v7 library. However, using this library required that I 
>> use the Fragment and FragmentPagerAdapter, etc. classes from the support.v4 
>> library (meaning that I also had to change my Activity to a 
>> FragmentActivity, call getSupportFragmentManager, etc.).
>>
>> Making no more than these changes, my ViewPager comes up as a blank 
>> screen; all I see is the ViewPager's background color; my fragments' views 
>> are not displayed! What's really strange is that by putting in various 
>> breakpoints, I can see that almost everything is working underneath as far 
>> as my fragments' life-cycle methods being called, etc. I can swipe back and 
>> forth across the screen and the fragments appear to be swapped in and out 
>> as expected. It is particularly telling, however, that in various custom 
>> views that I have, the onMeasure and onDraw methods are never called!
>>
>> Does anyone have any idea of what would be preventing the ViewPager from 
>> actually drawing its views? If I revert the code to use the native fragment 
>> support and associated supporting classes, everything shows up, which means 
>> that if there is something wrong on my end it must be extremely subtle.
>>
>> (Just to throw in some confusion, there is another activity in the app 
>> that also uses a ViewPager with fragments, and it continues to work with 
>> either the native or support library classes. (I'm about to throw in the 
>> towel and just forget this whole update.))
>>
>> Doug Gordon
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to android-d...@googlegroups.com 
>> 
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>> --- You received this message because you are subscribed to the Google 
>> Groups "Android Developers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to android-developers+unsubscr...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] ViewPager pages not drawn

2014-12-20 Thread Kostya Vasilyev
Ok, so the items are there and the views are there.

What I would do at this point is check the attributes (data) of those views:

- Their positions and sizes
- Visibility
- Animation state
- Translation / scaling
- Scroll positions

Or I would try to debug into the view pager's onMeasure / onLayout /
populate + scrollToItem

For this second part, I would perhaps add a button in the layout that calls
requestLayout or setCurrentItem on the pager, to trigger as needed.

-- K

2014-12-20 17:17 GMT+03:00 Doug Gordon :

> Kostya, I have done that and what I am seeing is the background of the
> ViewPager, but not my fragments' views. I set a breakpoint so I could go
> back into the ViewPager, and examining its data structure I find that not
> only does its mItems array contain my instantiated fragments, but also the
> mChildren array in the base View contains my fragments' expanded view
> hierarchies!
>
> There is just something that is preventing the views from being drawn,
> even if I explicitly call invalidate() on the ViewPager. And it still seems
> that it must have something to do with using the support.v4 fragment
> support since it all works fine using native fragments.
>
> On Friday, December 19, 2014 4:57:43 PM UTC-5, Kostya Vasilyev wrote:
>>
>> Have you tried debugging into ViewPager code?
>>
>> To see if your fragments' views are actually there and how they're laid
>> out?
>>
>> Another thing I often use in cases like this -- is to set the background
>> color of various views to distinct noticeable colors, like pink, cyan, etc.
>> In this case, I'd try the view pager itself, its parent view, and your
>> fragments' views.
>>
>> -- K
>>
>> 2014-12-20 0:30 GMT+03:00 Doug Gordon :
>>
>>> I haven't received any responses on stackoverflow about this, so am
>>> giving it a shot here.
>>>
>>> My app, which is fairly large and complex (hard to post meaningful code)
>>> uses as its main view a ViewPager with a FragmentPagerAdapter. Since the
>>> minSDK is 14, I originally wrote it to use the native Fragment and related
>>> classes (ViewPager from support.v4 and FragmentPagerAdapter from
>>> support.v13). This has all been working perfectly for a long time.
>>>
>>> Recently I decided to build in more compatibility, mainly for themes, by
>>> using the appcompat.v7 library. However, using this library required that I
>>> use the Fragment and FragmentPagerAdapter, etc. classes from the support.v4
>>> library (meaning that I also had to change my Activity to a
>>> FragmentActivity, call getSupportFragmentManager, etc.).
>>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] ViewPager pages not drawn

2014-12-20 Thread Doug Gordon
SOLVED! After tracing the execution through ViewPager and 
FragmentPagerAdapter and trying to explain the very strange behavior I was 
seeing, I eventually discovered that when I wrote my fragments extending 
Fragment and ListFragment a long time ago, I had added a getView() method 
that was (inadvertently) overriding the method by that name in the 
superclass and was returning the wrong view for what the ViewPager was 
expecting. I removed these methods and everything started working.

The only explanation I have for why this code was working OK with the 
native fragments is that I noticed that the support.v4 fragments enclose 
the fragment's actual root view as returned by onCreateView with some sort 
of FrameLayout that they create, and that is what getView returns. The 
native fragments apparently do not do this, so the view returned by my 
getView method worked correctly.

The only odd thing, and I am not a Java expert, is that I did not precede 
my getView with @Override and did not notice any error or warning about 
that. Isn't this required? I know that when I wrote that code that I was 
not intending to override the superclass.

On Saturday, December 20, 2014 1:04:23 PM UTC-5, Kostya Vasilyev wrote:
>
> Ok, so the items are there and the views are there.
>
> What I would do at this point is check the attributes (data) of those 
> views:
>
> - Their positions and sizes
> - Visibility
> - Animation state
> - Translation / scaling
> - Scroll positions
>
> Or I would try to debug into the view pager's onMeasure / onLayout / 
> populate + scrollToItem
>
> For this second part, I would perhaps add a button in the layout that 
> calls requestLayout or setCurrentItem on the pager, to trigger as needed.
>
> -- K
>
> 2014-12-20 17:17 GMT+03:00 Doug Gordon >:
>
>> Kostya, I have done that and what I am seeing is the background of the 
>> ViewPager, but not my fragments' views. I set a breakpoint so I could go 
>> back into the ViewPager, and examining its data structure I find that not 
>> only does its mItems array contain my instantiated fragments, but also the 
>> mChildren array in the base View contains my fragments' expanded view 
>> hierarchies!
>>
>> There is just something that is preventing the views from being drawn, 
>> even if I explicitly call invalidate() on the ViewPager. And it still seems 
>> that it must have something to do with using the support.v4 fragment 
>> support since it all works fine using native fragments.
>>
>> On Friday, December 19, 2014 4:57:43 PM UTC-5, Kostya Vasilyev wrote:
>>>
>>> Have you tried debugging into ViewPager code?
>>>
>>> To see if your fragments' views are actually there and how they're laid 
>>> out?
>>>
>>> Another thing I often use in cases like this -- is to set the background 
>>> color of various views to distinct noticeable colors, like pink, cyan, etc. 
>>> In this case, I'd try the view pager itself, its parent view, and your 
>>> fragments' views.
>>>
>>> -- K
>>>
>>> 2014-12-20 0:30 GMT+03:00 Doug Gordon :
>>>
 I haven't received any responses on stackoverflow about this, so am 
 giving it a shot here.

 My app, which is fairly large and complex (hard to post meaningful 
 code) uses as its main view a ViewPager with a FragmentPagerAdapter. Since 
 the minSDK is 14, I originally wrote it to use the native Fragment and 
 related classes (ViewPager from support.v4 and FragmentPagerAdapter from 
 support.v13). This has all been working perfectly for a long time.

 Recently I decided to build in more compatibility, mainly for themes, 
 by using the appcompat.v7 library. However, using this library required 
 that I use the Fragment and FragmentPagerAdapter, etc. classes from the 
 support.v4 library (meaning that I also had to change my Activity to a 
 FragmentActivity, call getSupportFragmentManager, etc.).

>>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.