Last updated
// Kotlin (Direct Jetpack Compose)
import androidx.compose.runtime.Composable
import com.tyrads.sdk.Tyrads
@Composable
fun MyCustomLayout() {
// Renders the Tyrads Premium Offer widget natively
Tyrads.getInstance().TopPremiumOffers(
widgetStyle = Tyrads.PremiumWidgetStyles.LIST // Or Tyrads.PremiumWidgetStyles.SLIDER_CARDS
)
}// Java Implementation (Instantiating dynamically via TyradsViewHelper)
import android.os.Bundle;
import android.widget.LinearLayout;
import androidx.appcompat.app.AppCompatActivity;
import com.tyrads.sdk.acmo.helpers.TyradsViewHelper;
import com.tyrads.sdk.acmo.modules.premium_widgets.TopPremiumOffersView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LinearLayout container = findViewById(R.id.widget_container);
// Dynamically instantiate the view using the built-in helper
TopPremiumOffersView premiumOffersView = TyradsViewHelper.createTopPremiumOffersView(
this, // Context
true, // showMore
false, // showMyOffers
false, // showMyOffersEmptyView
1 // style (0 = SLIDER_CARDS, 1 = LIST)
);
container.addView(premiumOffersView);
}
}<!-- XML Layout Integration (Available for both Kotlin & Java) -->
<com.tyrads.sdk.acmo.modules.premium_widgets.TopPremiumOffersView
android:id="@+id/premium_offers_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:showMore="true"
app:showMyOffers="false"
app:showMyOffersEmptyView="false"
app:style="1" /> <!-- 0 = SLIDER_CARDS, 1 = LIST -->