Ниже приведен xml, который я динамически раздуваю в Fragment. Однако когда я это делаю,
NativeAppInstallAdView add = (NativeAppInstallAdView) contentView.findViewById(R.id.adView);
Ссылка add обнуляется там, где другие представления, такие как
ImageView imgLogo = (ImageView) contentView.findViewById(R.id.ivLogo);
работают нормально. Я не могу понять, почему это здесь происходит. Любая помощь будет отличной.
<com.google.android.gms.ads.formats.NativeAppInstallAdView
xmlns:android = "http://schemas.android.com/apk/res/android"
android:id = "@+id/adView"
android:layout_width = "match_parent"
android:layout_height = "wrap_content">
<LinearLayout
android:id = "@+id/linearAdView"
android:layout_width = "match_parent"
android:focusable = "true"
android:layout_height = "wrap_content"
android:orientation = "vertical">
<TextView
android:id = "@+id/tvHeader"
android:layout_width = "match_parent"
android:layout_height = "wrap_content" />
<LinearLayout
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_marginTop = "2dp"
android:orientation = "horizontal">
<ImageView
android:id = "@+id/ivLogo"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content" />
<LinearLayout
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_marginLeft = "5dp"
android:orientation = "vertical">
<TextView
android:id = "@+id/tvDescription"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content" />
<RelativeLayout
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_marginTop = "1dp">
<TextView
android:id = "@+id/tvStore"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_alignParentLeft = "true" />
<TextView
android:id = "@+id/tvPrice"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_alignParentRight = "true" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<ImageView
android:id = "@+id/ivImage"
android:layout_width = "match_parent"
android:layout_height = "200dp"
android:layout_marginTop = "2dp"
android:background = "#00FFFFFF"
android:scaleType = "center" />
<Button
android:id = "@+id/btnAction"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_marginTop = "2dp"
android:paddingLeft = "10dp"
android:paddingRight = "10dp" />
</LinearLayout>
</com.google.android.gms.ads.formats.NativeAppInstallAdView>
добавленная ссылка становится нулевой при отладке
Вы пытались очистить свой проект, а затем построить его снова?
да, я пробовал аналогичный фрагмент в Activity, он там работает нормально, но при динамическом раздутии макета во фрагменте он дает null.
Что говорит ваш логарифм?