如何使用FB NativeAdapter

时间:2018-09-16 03:05:50

标签: android android-studio android-recyclerview facebook-ads-api

我是android的初学者。我正在创建一个新闻应用程序,该应用程序从JSON解析数据并将其显示在recyclerview中。我想在回收者视图之间放置Facebook原生广告。我找到了一个库,用于将FB原生广告与recyclerview集成在一起。但是我不知道怎么用请帮忙。

图书馆链接 https://github.com/ldt116/FBNativeAdAdapter

2 个答案:

答案 0 :(得分:0)

首先,您创建自己的自定义适配器 然后将其传递给FBNativeAdAdapter而不是传递给您的回收器视图,然后将FBNativeAdAdapter传递给您的回收器视图

        MyAdapter adapter = new MyAdapter();//create your own adapter
    FBNativeAdAdapter fbAdapter = FBNativeAdAdapter.Builder.with("469109283477914_473204296401746", adapter)
            .build();// pass it to fbAdapter 

    RecyclerView rv = (RecyclerView) findViewById(R.id.rv);

    rv.setLayoutManager(new LinearLayoutManager(this));//create layout manager and pass it to recyclerview
    rv.setAdapter(fbAdapter); //pass fbadapter to recycler view

答案 1 :(得分:0)

     FbNativeAdAdapter nativeadpater = FbNativeAdAdapter.Builder.with("your placement Id", recycleradapter).adIteminterval(addintervalnumberwhereyouwanttoshowad).build();

rv.setadapter(nativeadpater);