title: how can i add button Fragments,ViewPager using kotlin
body: <p>I want to add a button (id='Home') which take me to the main activity i use those codes but it is not reacting, this is a sample of my project in GITHUB please check it  from <a href="https://github.com/Aniskonig/ViewPagerwithSwipeAnimationinAndroid.git" rel="nofollow noreferrer">HERE</a> ( the problem has been fixed by @advice-dog , it has been added to the this project) </p>
  
  <p><strong>in layout of the ViewPager I have :</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/bg2"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:theme="@style/AppFullScreenTheme"
      tools:context=".License"&gt;
  
  
      &lt;android.support.v4.view.ViewPager
          android:id="@+id/view_pager"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:visibility="visible"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p><strong>in there class I have:</strong> </p>
  
  <pre><code>package com.medanis.fneclis
  
  
  import android.content.Intent
  import android.support.v7.app.AppCompatActivity
  import android.os.Bundle
  import android.support.v4.view.ViewPager
  import kotlinx.android.synthetic.main.activity_license.*
  
  
  class License : AppCompatActivity() {
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_license)
          val viewPager = findViewById&lt;ViewPager&gt;(R.id.view_pager)
          viewPager.adapter = CustomPagerAdapter(this)
  
      }
  }
  </code></pre>
  
  <p><strong>in the first PAGE of the ViewPager where I have the button Home:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/l1_bg"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@drawable/fneclis_l1_bg"
      tools:context=".AllButtons"&gt;
  
  
      &lt;Button
          android:id="@+id/Home"
          android:layout_width="56dp"
          android:layout_height="53dp"
          android:layout_marginBottom="523dp"
          android:layout_marginEnd="312dp"
          android:layout_marginLeft="16dp"
          android:layout_marginRight="312dp"
          android:layout_marginStart="16dp"
          android:layout_marginTop="16dp"
          android:background="@drawable/ic_home_black_24dp"
          android:contentDescription="@string/todo"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>which is related to the class AllButtons (I want to use it in the most pages of the ViewPage but not all of them):</p>
  
  <pre><code>package com.medanis.fneclis
  
  import android.content.Intent 
  import android.os.Bundle 
  import android.support.v7.app.AppCompatActivity 
  import kotlinx.android.synthetic.main.activity_l1_page.*
  
  class AllButtons: AppCompatActivity() {
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
         setContentView(R.layout.activity_l1_page)
  
  // those are some other pages which contains the same button and they are inside the ViewPager
             /* setContentView(R.layout.activity_l2_page)
              setContentView(R.layout.activity_l3_page)
              setContentView(R.layout.activity_m1page)
              setContentView(R.layout.activity_m2page)*/
  
          Home.setOnClickListener{
              val intent = Intent(this, MainActivity::class.java)
              startActivity(intent)
          }
      } }
  </code></pre>
  
  <p>THe ADAPTER :</p>
  
  <pre><code>package com.medanis.fneclis
  
  import android.app.Activity
  import android.content.Context
  import android.support.v4.view.PagerAdapter
  import android.view.LayoutInflater
  import android.view.View
  import android.view.ViewGroup
  
  class CustomPagerAdapter(private val mContext: Context) : PagerAdapter() {
  
      override fun instantiateItem(collection: ViewGroup, position: Int): Any {
          val modelObject = ModelObject.values()[position]
          val inflater = LayoutInflater.from(mContext)
          val viewGroup = inflater.inflate(modelObject.titleResId, collection, false) as ViewGroup
          collection.addView(viewGroup)
          return viewGroup
      }
  
      override fun destroyItem(collection: ViewGroup, position: Int, view: Any) {
          collection.removeView(view as View)
      }
  
      override fun getCount(): Int {
          return ModelObject.values().size
      }
  
      override fun isViewFromObject(view: View, `object`: Any): Boolean {
  
          return view === `object`
      }
  
      override fun getPageTitle(position: Int): CharSequence {
          val customPagerEnum = ModelObject.values()[position]
          return mContext.getString(customPagerEnum.titleResId)
      }
  
      override fun getItemPosition(`object`: Any): Int {
          return super.getItemPosition(`object`)
      }
  }
  </code></pre>
  
  <p>ModelObject :</p>
  
  <pre><code>package com.medanis.fneclis
  
  enum class ModelObject private constructor(val titleResId: Int ) {
  
      LICENSEONE(R.layout.activity_l1_page),
      PAGEONE(R.layout.activity_l1s1page),
      PAGETWO(R.layout.activity_l1s2page),
  
      LICENSETWO(R.layout.activity_l2_page),
      PAGETHREE(R.layout.activity_l2_s3page),
      PAGEFOUR(R.layout.activity_l2_s4page),
  
      LICENSETHREE(R.layout.activity_l3_page),
      PAGEFIVE(R.layout.activity_l3_s5page),
      PAGESIX(R.layout.activity_l3_s6page),
  
  }
  </code></pre>