title: How to setAdapter for carousel in motionlayout
body: <p>I am developing an app for that i used carousel with motion layout for image slider but i couldn't populate the carousel.
  And I am unable to set the adapter for the carousel how to populate the it with images or data.</p>
  <p>Once this basic motion scene is created, we only need to add a Carousel helper to the layout and references those views (in the same order we implemented our previous/next animation).</p>
  <p><strong>This is the XML file.</strong></p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;!-- activity_main.xml --&gt;
  &lt;androidx.constraintlayout.motion.widget.MotionLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_height=&quot;match_parent&quot;
      android:layout_width=&quot;match_parent&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      app:layoutDescription=&quot;@xml/activity_product_view_3d_scene&quot;&gt;
  
      &lt;ImageView  android:id=&quot;@+id/imageView0&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;400dp&quot;
          android:src=&quot;@drawable/nature2&quot;/&gt;
  
      &lt;ImageView  android:id=&quot;@+id/imageView1&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;400dp&quot;
          android:src=&quot;@drawable/nature1&quot;/&gt;
  
      &lt;ImageView  android:id=&quot;@+id/imageView2&quot;
      android:layout_width=&quot;match_parent&quot;
          android:src=&quot;@drawable/nature&quot;
      android:layout_height=&quot;400dp&quot; /&gt;
  
      &lt;androidx.constraintlayout.helper.widget.Carousel
          android:id=&quot;@+id/carousel&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          app:carousel_forwardTransition=&quot;@+id/forward&quot;
          app:carousel_backwardTransition=&quot;@+id/backward&quot;
          app:carousel_previousState=&quot;@+id/previous&quot;
          app:carousel_nextState=&quot;@+id/next&quot;
          app:carousel_infinite=&quot;true&quot;
          app:carousel_firstView=&quot;@+id/imageView2&quot;
          app:constraint_referenced_ids=&quot;imageView0,imageView1&quot; /&gt;
  
  &lt;/androidx.constraintlayout.motion.widget.MotionLayout&gt;
  </code></pre>
  <p><strong>This is the motion scenefile.</strong></p>
  <pre class="lang-xml prettyprint-override"><code>   &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
     &lt;MotionScene 
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:motion=&quot;http://schemas.android.com/apk/res-auto&quot;&gt;
  
      &lt;Transition
          motion:constraintSetStart=&quot;@id/start&quot;
          motion:constraintSetEnd=&quot;@+id/next&quot;
          motion:duration=&quot;1000&quot;
          android:id=&quot;@+id/forward&quot;&gt;
          &lt;OnSwipe
              motion:dragDirection=&quot;dragLeft&quot;
              motion:touchAnchorSide=&quot;left&quot; /&gt;
      &lt;/Transition&gt;
  
      &lt;Transition
          motion:constraintSetStart=&quot;@+id/start&quot;
          motion:constraintSetEnd=&quot;@+id/previous&quot;
          android:id=&quot;@+id/backward&quot;&gt;
          &lt;OnSwipe
              motion:dragDirection=&quot;dragRight&quot;
              motion:touchAnchorSide=&quot;right&quot; /&gt;
      &lt;/Transition&gt;
  
  &lt;/MotionScene&gt;
  </code></pre>
  <p><strong>This is the .java file.</strong></p>
  <pre class="lang-java prettyprint-override"><code>    
  public class ProductView_3d extends AppCompatActivity {
      
          Carousel carousel;
          int [] images = {R.drawable.nature1, R.drawable.nature, R.drawable.nature2};
      
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_product_view_3d);
      
              carousel = findViewById(R.id.carousel);
      
              carousel.setAdapter(new Carousel.Adapter() {
                  @Override
                  public int count() {
                      return images.length;
                  }
      
                  **@Override
                  public void populate(View view, int index){
                  }**
      
                  @Override
                  public void onNewItem(int index) {
      
                  }
              });
          }
      }
  </code></pre>
  <p>I implemented from the official documentation of android <a href="https://developer.android.com/training/constraint-layout/motionlayout/carousel" rel="nofollow noreferrer">link here</a></p>
  <p><strong>But I am unable to populate the carousel could anyone help.
  Thanks in advance.</strong></p>