我已经与Mopub集成在我的Android应用程序中显示广告.我可以展示bannner和插页式广告,但不能展示原生广告,
布局文件代码,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/note_title_label"
style="?android:listSeparatorTextViewStyle"
/>
<EditText android:id="@+id/note_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/note_title_hint"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/note_details_label"
style="?android:listSeparatorTextViewStyle"
/>
<EditText android:id="@+id/note_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/note_details_hint"
/>
<Button android:id="@+id/note_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
/>
<CheckBox android:id="@+id/note_solved"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:text="@string/note_solved_label"
/>
<RelativeLayout android:id="@+id/native_ad_layout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="50dp">
>
<ImageView android:id="@+id/native_ad_main_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<ImageView android:id="@+id/native_ad_icon_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView android:id="@+id/native_ad_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView android:id="@+id/native_ad_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</RelativeLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
fragment.java中的逻辑(与上面的布局相关联)用于显示原生广告的文件,
@TargetApi(11) …Run Code Online (Sandbox Code Playgroud)