title: New leanaback's LeanbackTabLayout and LeanbackViewPager not focusing and changing tab with D-PAD controller
body: <blockquote>
  <p>I am using new leanback tab and viewpager. I am not able to change tab1 to tab2 with D-pad. Tabs changes from Tab1 to Tab2 when i reach to last item of rowfragment in Tab1. I am not able to jump to up from rowfragment item to Tab menu. I have mentioned code sample below. In developer video they are able switch tabs with d-pad. please answer this. thanks in advance :)</p>
  </blockquote>
  <p>my build.gradle file :</p>
  <pre><code>implementation fileTree(dir: &quot;libs&quot;, include: [&quot;*.jar&quot;])
  implementation &quot;org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version&quot;
  implementation 'androidx.core:core-ktx:1.3.2'
  implementation 'androidx.leanback:leanback:1.0.0'
  implementation &quot;androidx.leanback:leanback-tab:1.1.0-beta01&quot;
  implementation 'androidx.appcompat:appcompat:1.2.0'
  implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
  implementation 'androidx.legacy:legacy-support-v4:1.0.0'
  implementation 'com.github.bumptech.glide:glide:3.8.0'
  </code></pre>
  <p>Fragment file:</p>
  <pre><code>class CollectionDemoFragment : Fragment() {
  private lateinit var demoCollectionPagerAdapter : DemoCollectionPagerAdapter
  private lateinit var viewPager : LeanbackViewPager
  private lateinit var tab_layout : LeanbackTabLayout
  
  override fun onCreateView(
      inflater: LayoutInflater, container: ViewGroup?,
      savedInstanceState: Bundle?): View? {
      return inflater.inflate(R.layout.collection_demo, container, false)
  }
  
  override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
      demoCollectionPagerAdapter = DemoCollectionPagerAdapter(childFragmentManager)
      viewPager = view.findViewById(R.id.pager)
      viewPager.setKeyEventsEnabled(true)
  
      tab_layout = view.findViewById(R.id.tab_layout)
      viewPager.adapter = demoCollectionPagerAdapter
      tab_layout.setupWithViewPager(viewPager)
  }
  </code></pre>
  <p>}</p>
  <p>Fragment Xml file:</p>
  <pre><code>&lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  xmlns:tools=&quot;http://schemas.android.com/tools&quot;
  xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
  android:orientation=&quot;vertical&quot;
  android:layout_width=&quot;match_parent&quot;
  android:layout_height=&quot;match_parent&quot;
  android:padding=&quot;16dp&quot;
  tools:context=&quot;.CollectionDemoFragment&quot;
  android:background=&quot;@android:color/white&quot;&gt;
  
  
  &lt;androidx.leanback.tab.LeanbackViewPager
      android:id=&quot;@+id/pager&quot;
      android:layout_below=&quot;@+id/relativeLayout&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;&gt;
  
      &lt;androidx.leanback.tab.LeanbackTabLayout
          android:id=&quot;@+id/tab_layout&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:background=&quot;@color/lb_grey&quot;
          android:focusable=&quot;true&quot;
          android:focusableInTouchMode=&quot;true&quot;/&gt;
  
  &lt;/androidx.leanback.tab.LeanbackViewPager&gt;
  </code></pre>
  
  <p>Adapter file:</p>
  <pre><code>class DemoCollectionPagerAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) {
  override fun getItem(position: Int): Fragment {
      val fragment = DemoObjectFragment()
      fragment.arguments = Bundle().apply {
          putInt(ARG_OBJECT, position + 1)
      }
      return fragment
  }
  
  override fun getCount(): Int = 4
  
  
  override fun getPageTitle(position: Int): CharSequence {
      return &quot;OBJECT ${(position + 1)}&quot;
  }
  </code></pre>
  <p>}</p>
  <p>I have gone through developer site and youtube video as well:
  <a href="https://developer.android.com/training/tv/start/libraries#leanback-tabs-library" rel="nofollow noreferrer">https://developer.android.com/training/tv/start/libraries#leanback-tabs-library</a></p>
  <p><a href="https://www.youtube.com/watch?v=OOV6Ef9zDg0&amp;t=1065s" rel="nofollow noreferrer">https://www.youtube.com/watch?v=OOV6Ef9zDg0&amp;t=1065s</a> at 16:40 seconds</p>
  <p>For more clarity i have Added image of screen. In image, I am not able to go from Selected item -&gt; Tab2 -&gt; Tab3. And now other hand, If i am at last item of Tab2 and then i click on D-pad right then and only it move to Tab3 and vice-versa first item at Tab3 then i can able to move to Tab2. Hope this clear my problem.</p>
  <p><a href="https://i.stack.imgur.com/Syvb1.png" rel="nofollow noreferrer">https://i.stack.imgur.com/Syvb1.png</a></p>