4

我正在尝试在 BrowseFragment 之外重用 AndroidTV Leanback 提供的 RowsFragment,以在不同的布局上具有类似的行交互外观,但我遇到了无法调试的 XML 膨胀错误和解决。

实现本身与此处实现的类似:https ://medium.com/building-for-android-tv : //medium.com/building-for-android-tv,但在博客中,他在 BrowseFragment 中替换了相同类型的不同片段。我的方法有什么根本错误吗?如果是这样,为什么?我一直在阅读 Leanback 资源,但找不到任何我能理解的东西(尽管它是一个大型图书馆),可以将片段耦合到那种程度。

相关代码的复制:
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
4

1 回答 1

3

确保您的ChangePicActivity在 AndroidManifest.xml 中有正确的主题

android:theme="@style/Theme.Leanback"添加到相关活动标签。像这样

 <activity
        android:name=".ChangePicActivity"
        android:theme="@style/Theme.Leanback"
 >
[...]
于 2015-06-22T22:34:38.607 回答