Android - SDK-dokumentation för att tjäna pengar på appar

⌘K
  1. Android - Tjäna pengar på app SD...
  2. Använd manual
  3. Annonsformat
  4. Oändlig skroll

Oändlig skroll

Förutsättningar

We need you to edit your item Layout, so it has a wrapper/holder for the Ads. Keep in mind this wrapper/holder could be expanded or contracted, so make sure your layout adapts to this changes look into adaptive layouts for this, this size changes in the layout will be limited by the ad configurations that the infinite scroll is using, these can be edited in the code on manual initialization, or in our dashboard in case of auto and single tag initialization.

This is because we can not edit your data for adding new items to the adapter, so we take the existing item views and add the ads to them. You can customize which items have ads when you create the configuration for the infinite scroll.



.

Get the RecyclerView

      // Find your view, this is the simplest but there are better ways
      val rv = findViewById<RecyclerView>(R.id.infiniteScroll_recyclerView_manual)
      
      // Create and use your own adapter
      rv.adapter = <add your adapter>
      
      // Linear layout is the most common but feel free to swap it
      rv.layoutManager = LinearLayoutManager(this)

Prepare the Item View

Normal item Code would look something like

      <?xml version="1.0" encoding="utf-8"?>
      <androidx.constraintlayout.widget.ConstraintLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginStart="10dp"
          android:layout_marginEnd="10dp">
      
          <Button
              android:id="@+id/infinitescroll_item_button_auto"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:text="Button"
              app:layout_constraintBottom_toBottomOf="parent"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toTopOf="parent"
              app:layout_constraintVertical_bias="0.0" />
      
      </androidx.constraintlayout.widget.ConstraintLayout>

For adding the wrapper to this item we would do something like

      <?xml version="1.0" encoding="utf-8"?>
      <androidx.constraintlayout.widget.ConstraintLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginStart="10dp"
          android:layout_marginEnd="10dp">
      
          <Button
              android:id="@+id/infinitescroll_item_button_auto"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:text="Button"
              app:layout_constraintBottom_toBottomOf="parent"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toTopOf="parent"
              app:layout_constraintVertical_bias="0.0" />
      
          <FrameLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:tag="infiniteScroll_ad_wrapper_tag"
              app:layout_constraintBottom_toBottomOf="parent"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toBottomOf="@+id/infinitescroll_item_button_auto"
              app:layout_constraintVertical_bias="0.0">
          </FrameLayout>
      
      </androidx.constraintlayout.widget.ConstraintLayout>

Visa annonsen

I exemplet använder vi ett test-ID.

Om du inte testar appen, ändra den till rätt ID som du fick av oss.



.

      # MainActivity.kt
      val infiniteScrollConfigId = ConfigBuilder.INFINITE_SCROLL_TEST_R89_CONFIG_ID
      val itemAdWrapperTag = <Defined ad wrapper tag for each item view that's going to be in the recycler view>
      RefineryAdFactory.createInfiniteScroll(infiniteScrollConfigId, rv, itemAdWrapperTag)

Händelser under livscykeln

Du kan prenumerera på dessa händelser med samma metod men genom att skicka ett nytt objekt som parameter. Detaljer om detta objekt finns i Referens.

              # MainActivity.kt
              val infiniteScrollConfigId = ConfigBuilder.BANNER_TEST_R89_CONFIG_ID
              val infiniteScrollLifecycleListener = <create the listener with a method or inline>
              RefineryAdFactory.createInfiniteScroll(infiniteScrollConfigId, rv, infiniteScrollLifecycleListener)

Hur kan vi hjälpa till?