title: How to use TabHost in Kotlin
body: <p>I would like to make a TabHost with 3 tabs in Kotlin.</p>
  
  <p>When the fragment is launch, it set a tabHost with 3 tabs, and in each tab, there is 1 fragment: Infos, news, and contact.</p>
  
  <p>Here is how I set the tabs in my fragment :</p>
  
  <pre><code>var spec = binding.tabHost.newTabSpec(TAG_INFOS)
  spec.setContent(R.id.tab_infos)
  spec.setIndicator(getString(R.string.infos))
  binding.tabHost.addTab(spec)
  
  spec = binding.tabHost.newTabSpec(TAG_NEWS)
  spec.setContent(R.id.tab_news)
  spec.setIndicator(getString(R.string.news))
  binding.tabHost.addTab(spec)
  
  spec = binding.tabHost.newTabSpec(TAG_CONTACT)
  spec.setContent(R.id.tab_contact)
  spec.setIndicator(getString(R.string.contact))
  binding.tabHost.addTab(spec)
  </code></pre>
  
  <p>Now I try to set a kind of onClickListener but for tabs, like this :</p>
  
  <pre><code>binding.tabHost.setOnTabChangedListener(TabHost.OnTabChangeListener() {
      @Override
      fun onTabChange(tabId: String) {
          if (TAG_INFOS.equals(tabId)) {
          fragmentManager.beginTransaction().replace(R.id.tab_infos, infosFragment, TAG_INFOS)
           }
           if (TAG_NEWS.equals(tabId)) {
               println("IF NEWS")
           }
           if (TAG_CONTACT.equals(tabId)) {
                println("IF CONTACT")
           }
       }
  })
  </code></pre>
  
  <p>But this does not seems to work, I don't even know how to use the onTabChange func.</p>
  
  <p>I already tried:</p>
  
  <pre><code>fragmentManager.beginTransaction().replace(R.id.tab_infos, infosFragment, TAG_INFOS)
  </code></pre>
  
  <p>but it only set my fragment layout, without allowing me to modify the data inside from a <code>ViewModel</code></p>
  
  <p>How can I set a fragment in each tab? What is the syntax?</p>