Bug 24102 - Android Wear - Cannot get GridViewPager working on a basic sample
Summary: Android Wear - Cannot get GridViewPager working on a basic sample
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.20.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2014-10-28 10:13 UTC by David Poulin
Modified: 2014-10-28 13:54 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Basic Sample for GridViewPager (16.29 KB, application/x-zip-compressed)
2014-10-28 10:13 UTC, David Poulin
CardFrame default template (297.46 KB, image/jpeg)
2014-10-28 13:05 UTC, David Poulin

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description David Poulin 2014-10-28 10:13:17 UTC
Created attachment 8529 [details]
Basic Sample for GridViewPager


I tried to use on an Android Wear app the GridViewPager view. I can not get it working whatever I can do.

I create a simple android app with all the requirements to run it as an android wear app (added all the dependencies).

First, i tried to run project with default implementation, i got exception :

[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: SimpleGridViewWear.SimpleGridViewWear, PID: 4643
[AndroidRuntime] java.lang.NullPointerException
[AndroidRuntime] 	at android.support.wearable.view.GridViewPager.populate(GridViewPager.java:900)
[AndroidRuntime] 	at android.support.wearable.view.GridViewPager.populate(GridViewPager.java:848)
[AndroidRuntime] 	at android.support.wearable.view.GridViewPager.onMeasure(GridViewPager.java:1141)
[AndroidRuntime] 	at android.view.View.measure(View.java:16648)
[AndroidRuntime] 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
[AndroidRuntime] 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
[AndroidRuntime] 	at android.view.View.measure(View.java:16648)
[AndroidRuntime] 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
[AndroidRuntime] 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
[AndroidRuntime] 	at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2338)
[AndroidRuntime] 	at android.view.View.measure(View.java:16648)
[AndroidRuntime] 	at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1959)
[AndroidRuntime] 	at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1145)
[AndroidRuntime] 	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1396)
[AndroidRuntime] 	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1032)
[AndroidRuntime] 	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5657)
[AndroidRuntime] 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
[AndroidRuntime] 	at android.view.Choreographer.doCallbacks(Choreographer.java:574)
[AndroidRuntime] 	at android.view.Choreographer.doFrame(Choreographer.java:544)
[AndroidRuntime] 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
[AndroidRuntime] 	at android.os.Handler.handleCallback(Handler.java:733)
[AndroidRuntime] 	at android.os.Handler.dispatchMessage(Handler.java:95)
[AndroidRuntime] 	at android.os.Looper.loop(Looper.java:136)
[AndroidRuntime] 	at android.app.ActivityThread.main(ActivityThread.java:5026)
[AndroidRuntime] 	at java.lang.reflect.Method.invokeNative(Native Method)
[AndroidRuntime] 	at java.lang.reflect.Method.invoke(Method.java:515)
[AndroidRuntime] 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
[AndroidRuntime] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
[AndroidRuntime] 	at dalvik.system.NativeStart.main(Native Method)
[Process] Sending signal. PID: 4643 SIG: 9

Then, I tried also too implement default required interface for View (View.IOnApplyWindowInsetsListener). but it does not exists

I also tried to run all your samples using a GridViewPager, I can not get any of them working (for example that one : https://github.com/xamarin/monodroid-samples/tree/master/wear/GridViewPager). Because of the interface.

Is it a bug or do we have to install other components ?

I have added my sample zipped into this report.

Thanks you for your feedback,

Comment 1 Jérémie Laval 2014-10-28 10:58:35 UTC

This is a bug in the Google library itself. If you don't set an adapter it likes before doing a layout pass it will blow up like this.

If you are loading dynamically, you can use the same trick I do which is to set your GridViewPager as visibility=gone (https://github.com/garuma/Moyeu/blob/master/MoyeuWear/Resources/layout/Main.axml#L8) to bypass it during layout and then enable it when you actually set the data (https://github.com/garuma/Moyeu/blob/master/MoyeuWear/MainActivity.cs#L132)
Comment 2 David Poulin 2014-10-28 11:08:48 UTC
Oki Jérémie. I will have a try right now. But what about the interface View.IOnApplyWindowInsetsListener that you are using on few samples ? If I want to override WindowsInsets. You have also a trick ?
Comment 3 David Poulin 2014-10-28 11:20:32 UTC
Mmm, I will have an issue however, because, I am not loading data dynamically. Like i can not use WearableListView (i already submit a bug on it), i wanted to use the GridViewPager like a kind of menu, so, all my data are static and existing in my adapter at runtime.

Is there any way I can get it working ? (I tried to set my adapter on the Start LifeCycle event, but I got the same issue).

Thank you for your answer!
Comment 4 David Poulin 2014-10-28 11:25:04 UTC
Sorry, I got it working, i had just forgotten the base.OnStart() in my overrided OnStart method. Now, I am entering another issue regarding the default style of the CardFrame :-). If you have tricks...
Comment 5 Jérémie Laval 2014-10-28 11:30:30 UTC
GridViewPager normally handles the windows insets automatically for you (by either expanding the whole width on round or adding margin on square) so you shouldn't need to do anything. For this to work you shouldn't intercept the inset event (i.e. derive your main activity from Activity directly rather than InsetActivity).
Comment 6 David Poulin 2014-10-28 13:05:53 UTC
Created attachment 8531 [details]
CardFrame default template

Hi again,

I have added an image of the default CardFrame style generated on my phone. Is there any way to get default style without having to extract the styles in a Android Studio project ?

Thank you !


ps: it is my last question and I will closed this thread
Comment 7 Jérémie Laval 2014-10-28 13:54:52 UTC
This is actually due to a different bug we have, see https://bugzilla.xamarin.com/show_bug.cgi?id=23835

We are going to release very soon an updated 4.18.1 build that fix this issue.