4

I'm trying to reuse the RowsFragment provided by AndroidTV Leanback outside of a BrowseFragment, to have a similar row interaction look & feel on a different layout, but I'm getting XML-inflation errors that I haven't been able to debug and solve.

The implementation itself is similar to what is implemented here: https://medium.com/building-for-android-tv , but in the blog he's replacing different fragments of the same kind inside a BrowseFragment. Is there something fundamentally wrong with my approach? If so, why? I've been reading through the Leanback sources and haven't been able to find anything that I would understand (although it's a large library) that would couple the fragments to that degree.

A reproduction of the relevant code:
https://gist.github.com/orbitbot/c9070ed00961c3abe4ca

02-26 12:12:26.950    4465-4527/com.my.client E/AndroidRuntime﹕ FATAL EXCEPTION: main
      Process: com.my.client, PID: 4465
      android.view.InflateException: Binary XML file line #18: Error inflating class <unknown>
              at android.view.LayoutInflater.createView(LayoutInflater.java:620)
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
              at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:462)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
              at android.support.v17.leanback.widget.RowContainerView.<init>(RowContainerView.java:48)
              at android.support.v17.leanback.widget.RowContainerView.<init>(RowContainerView.java:37)
              at android.support.v17.leanback.widget.RowPresenter.onCreateViewHolder(RowPresenter.java:169)
              at android.support.v17.leanback.widget.ItemBridgeAdapter.onCreateViewHolder(ItemBridgeAdapter.java:247)
              at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:4121)
              at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3431)
              at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3340)
              at android.support.v17.leanback.widget.GridLayoutManager.getViewForPosition(GridLayoutManager.java:573)
              at android.support.v17.leanback.widget.GridLayoutManager$2.createItem(GridLayoutManager.java:1057)
              at android.support.v17.leanback.widget.StaggeredGrid.appendItemToRow(StaggeredGrid.java:242)
              at android.support.v17.leanback.widget.StaggeredGridDefault.appendItems(StaggeredGridDefault.java:49)
              at android.support.v17.leanback.widget.GridLayoutManager.appendOneVisibleItem(GridLayoutManager.java:1263)
              at android.support.v17.leanback.widget.GridLayoutManager.appendVisibleItems(GridLayoutManager.java:1273)
              at android.support.v17.leanback.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:1554)
              at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:1988)
              at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:2237)
              at android.view.View.layout(View.java:14817)
              at android.view.ViewGroup.layout(ViewGroup.java:4631)
              at android.support.v17.leanback.widget.ScaleFrameLayout.onLayout(ScaleFrameLayout.java:135)
              at android.view.View.layout(View.java:14817)
              at android.view.ViewGroup.layout(ViewGroup.java:4631)
              at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
              at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
              at android.view.View.layout(View.java:14817)
              at android.view.ViewGroup.layout(ViewGroup.java:4631)
              at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
              at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
              at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
              at android.view.View.layout(View.java:14817)
              at android.view.ViewGroup.layout(ViewGroup.java:4631)
              at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
              at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
              at android.view.View.layout(View.java:14817)
              at android.view.ViewGroup.layout(ViewGroup.java:4631)
              at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
              at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
              at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
              at android.view.View.layout(View.java:14817)
              at android.view.ViewGroup.layout(ViewGroup.java:4631)
              at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
              at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
              at android.view.View.layout(View.java:14817)
              at android.view.ViewGroup.layout(ViewGroup.java:4631)
              at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1989)
              at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1746)
              at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
              at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5672)
              at android.view.Choreographer$CallbackRecord.run(Choreographer.java:772
orbitbot
  • 728
  • 6
  • 18
  • 1
    I'm the author of that series of articles. It's not so clear to me what you're trying to achieve and how it differs from what I've done with the custom BrowseFragment implementation. – Sebastiano Feb 26 '15 at 09:45
  • OK, got it. It does look right at a first glance. I'm going to give it a spin and see if I can understand what's going on. – Sebastiano Feb 26 '15 at 10:11
  • Cool, thanks for the effort! I'm about to add more fragments to the layout later, so the RowsFragment would only be a part of it (approximately a lower half). – orbitbot Feb 26 '15 at 10:13

1 Answers1

3

Make sure that your ChangePicActivity has proper theme in AndroidManifest.xml

Add android:theme="@style/Theme.Leanback" to relevant activity tag. Like this

 <activity
        android:name=".ChangePicActivity"
        android:theme="@style/Theme.Leanback"
 >
[...]
pelotasplus
  • 9,852
  • 1
  • 35
  • 37
  • Thanks for the tip! Obvious when you realize it, but we we're messing with the themes on a per-activity basis because of legacy reasons. – orbitbot Jul 01 '15 at 15:09