William L. William L. - 3 days ago 6
Android Question

Don't let AdMob ads request focus?

I have a EditText in a layout, and I also have AdMob ads at the bottom of the layout, when someone enters something in the EditText theres suppose to be a "Done" button in the button right corner of the keyboard, but after I added AdMob it has a "Next" button, and when you press it, it focuses on the Ad! Is there a way to disable this?

My XML:

<com.google.ads.AdView android:id="@+id/adView"
android:focusable="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="XXXXXXXXXXX"
ads:adSize="BANNER"
ads:testDevices="XXXXXXXXXXX"/>


My Java:

if (showAds == true) {
AdView adView = (AdView)this.findViewById(R.id.adView);
adView.loadAd(new AdRequest());
}


Note: I dont know if this matters, but I am using a ViewPager so the AdView is on my Main.xml layout file and the EditText is on the Layout that my ViewPager inflates.

Answer

If you want to retain the "Done" button in your EditText, add this attribute to it: android:imeOptions="actionDone". This will force the "Done" button to appear on soft keyboards.

If you want to retain the "Next" button instead, and have it skip the AdView, you can use this method to skip over the AdView when hitting "Next".

Comments