Adding Facebook Native Ads in ListView – android 2016

Hey Guyz. In this post, I am going to show you how to add Facebook Native Ads on your Android Application ListView. If you are here, I believe you know what is Native Ads. If not check this link out Facebook Native ads Introduction
Facebook native ads are a good way to provide similar look and feel to the ads. I was introduced to Facebook Native ads a week ago while I was working for one of our Clients app Yoo – Free Recharge App But the issue with Facebook Native ads is Internet don’t have much Tutorials on it. So i decided to make one.

Wanted HackerKernel to work on your Dream Project – Contact Us

Facebook native ads in ListView android

Step 1. Create an app on Facebook

Follow the give steps and create an app on facebook and Note down your Placement ID Steps to create Facebook APP

Step 2. Create a new Android Studio Project

Open Android Studio and create an new Android project

Step 3. Add permissions to Mainfest

Adding internet and access network state permission in AndroidManifest.xml
[xml]


[/xml]

Step 4. Adding dependency

We will be adding Volley and Facebook Audience Network dependency in order to downloading data from the web & adding Native ads
[java]
dependencies {
compile fileTree(dir: ‘libs’, include: [‘*.jar’])
testCompile ‘junit:junit:4.12’
compile ‘com.android.support:appcompat-v7:23.1.1’
compile ‘com.android.volley:volley:1.0.0’
compile ‘com.facebook.android:audience-network-sdk:4.+’
}
[/java]

Step 5. Creating layout

We will create activity_main.xml file. This file will have a listView

activity_main.xml

[xml]



[/xml]

We will create two more Layout one for list list_row.xml and one for ads ad_list.xml

list_row.xml

[xml]


[/xml]

ad_list.xml

[xml]