Этот код работает хорошо, без его части.Я не могу добавить admob в макет Android-студии.Как добавить AdMob в макет, пожалуйста, посмотрите мой код.Помогите мне добавить в admob.Code без ошибок, только объявление не отображается в макете.пожалуйста, кто-нибудь подскажет, какую часть нужно отредактировать.спасибо
<?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="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="70dp"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/difficulty_margin"
android:layout_marginTop="30dp"
android:layout_marginRight="@dimen/difficulty_margin"
android:layout_marginBottom="30dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<com.nayemuzzaman.kidsmemorize.ui.DifficultyView
android:id="@+id/select_difficulty_1"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_weight="1" />
<TextView
android:id="@+id/time_difficulty_1"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginTop="-40dp"
android:layout_marginBottom="18dp"
android:background="@drawable/time_border"
android:textSize="17sp" />
<com.nayemuzzaman.kidsmemorize.ui.DifficultyView
android:id="@+id/select_difficulty_4"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_weight="1" />
<TextView
android:id="@+id/time_difficulty_4"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginTop="-40dp"
android:background="@drawable/time_border"
android:textSize="17sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/difficulty_margin"
android:layout_marginTop="30dp"
android:layout_marginRight="@dimen/difficulty_margin"
android:layout_marginBottom="30dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<com.nayemuzzaman.kidsmemorize.ui.DifficultyView
android:id="@+id/select_difficulty_2"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_weight="1" />
<TextView
android:id="@+id/time_difficulty_2"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginTop="-40dp"
android:layout_marginBottom="18dp"
android:background="@drawable/time_border"
android:textSize="17sp" />
<com.nayemuzzaman.kidsmemorize.ui.DifficultyView
android:id="@+id/select_difficulty_5"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_weight="1" />
<TextView
android:id="@+id/time_difficulty_5"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginTop="-40dp"
android:background="@drawable/time_border"
android:textSize="17sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/difficulty_margin"
android:layout_marginTop="30dp"
android:layout_marginRight="@dimen/difficulty_margin"
android:layout_marginBottom="30dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<com.nayemuzzaman.kidsmemorize.ui.DifficultyView
android:id="@+id/select_difficulty_3"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_weight="1" />
<TextView
android:id="@+id/time_difficulty_3"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginTop="-40dp"
android:layout_marginBottom="18dp"
android:background="@drawable/time_border"
android:textSize="17sp" />
<com.nayemuzzaman.kidsmemorize.ui.DifficultyView
android:id="@+id/select_difficulty_6"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_weight="1" />
<TextView
android:id="@+id/time_difficulty_6"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginTop="-40dp"
android:background="@drawable/time_border"
android:textSize="17sp" />
</LinearLayout>
</LinearLayout>
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_marginTop="@dimen/margintoptendp"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_adUnitId" />
</LinearLayout>
DifficultySelectFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = LayoutInflater.from(Shared.context).inflate(R.layout.difficulty_select_fragment, container, false);
Theme theme = Shared.engine.getSelectedTheme();
DifficultyView difficulty1 = view.findViewById(R.id.select_difficulty_1);
difficulty1.setDifficulty(1, Memory.getHighStars(theme.id, 1));
setOnClick(difficulty1, 1);
/* FIrstFragment fIrstFragment = new FIrstFragment();
moveToFragment(fIrstFragment);*/
DifficultyView difficulty2 = view.findViewById(R.id.select_difficulty_2);
difficulty2.setDifficulty(2, Memory.getHighStars(theme.id, 2));
setOnClick(difficulty2, 2);
DifficultyView difficulty3 = view.findViewById(R.id.select_difficulty_3);
difficulty3.setDifficulty(3, Memory.getHighStars(theme.id, 3));
setOnClick(difficulty3, 3);
DifficultyView difficulty4 = view.findViewById(R.id.select_difficulty_4);
difficulty4.setDifficulty(4, Memory.getHighStars(theme.id, 4));
setOnClick(difficulty4, 4);
DifficultyView difficulty5 = view.findViewById(R.id.select_difficulty_5);
difficulty5.setDifficulty(5, Memory.getHighStars(theme.id, 5));
setOnClick(difficulty5, 5);
DifficultyView difficulty6 = view.findViewById(R.id.select_difficulty_6);
difficulty6.setDifficulty(6, Memory.getHighStars(theme.id, 6));
setOnClick(difficulty6, 6);
animate(difficulty1, difficulty2, difficulty3, difficulty4, difficulty5, difficulty6);
Typeface type = Typeface.createFromAsset(Shared.context.getAssets(), "fonts/grobold.ttf");
TextView text1 = view.findViewById(R.id.time_difficulty_1);
text1.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
text1.setTypeface(type);
text1.setText(getBestTimeForStage(theme.id, 1));
TextView text2 = view.findViewById(R.id.time_difficulty_2);
text2.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
text2.setTypeface(type);
text2.setText(getBestTimeForStage(theme.id, 2));
TextView text3 = view.findViewById(R.id.time_difficulty_3);
text3.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
text3.setTypeface(type);
text3.setText(getBestTimeForStage(theme.id, 3));
TextView text4 = view.findViewById(R.id.time_difficulty_4);
text4.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
text4.setTypeface(type);
text4.setText(getBestTimeForStage(theme.id, 4));
TextView text5 = view.findViewById(R.id.time_difficulty_5);
text5.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
text5.setTypeface(type);
text5.setText(getBestTimeForStage(theme.id, 5));
TextView text6 = view.findViewById(R.id.time_difficulty_6);
text6.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
text6.setTypeface(type);
text6.setText(getBestTimeForStage(theme.id, 6));
mAdview = view.findViewById( R.id.adView );
AdRequest adRequest = new AdRequest.Builder().tagForChildDirectedTreatment(true).build();
mAdview.loadAd( adRequest );
return view;
}