Note that there are some explanatory texts on larger screens.

plurals
  1. PODeclaring RelativeLayout footer in code
    primarykey
    data
    text
    <p>I tried almost everything. I decided that putting ads in XML isn't safe way so i wanted to do that through code. This is how i made this in XML</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;com.google.ads.AdView android:id="@+id/adViewContactsList" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" ads:adUnitId="My Unit id" ads:adSize="BANNER" ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" ads:loadAdOnCreate="true"/&gt; &lt;FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:layout_weight="200" android:layout_above="@id/adViewContactsList"&gt; &lt;ListView android:id="@+id/contactsList" android:layout_width="fill_parent" android:layout_height="fill_parent" android:cacheColorHint="#0000" android:listSelector="@drawable/listview_background_pressed" android:divider="@color/convListSep" android:dividerHeight="0.5dp" android:fadingEdge="none" android:scrollingCache="false" &gt; &lt;/ListView&gt; &lt;View android:layout_width="fill_parent" android:layout_height="5dp" android:background="@drawable/background_shadow" /&gt; &lt;/FrameLayout&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Every time i tried to make footer for Ads through it works like FrameLayout only (it covers bottom part of list). This is my code (of course after deleting ads in XML)</p> <pre><code>adView = new AdView(this, AdSize.BANNER, GateSMSApp.AD_ID); RelativeLayout layout = (RelativeLayout)findViewById(R.id.layoutContactsList); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); adView.setLayoutParams(params); AdRequest adRequest = new AdRequest(); adRequest.addTestDevice(AdRequest.TEST_EMULATOR); adView.loadAd(adRequest); layout.addView(adView); RelativeLayout.LayoutParams frameLayoutParams = (RelativeLayout.LayoutParams) findViewById(R.id.frameLayoutList).getLayoutParams(); FrameLayout frameList = (FrameLayout) findViewById(R.id.frameLayoutList); RelativeLayout.LayoutParams viewParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); viewParams.addRule(RelativeLayout.ABOVE, adView.getId()); frameList.setLayoutParams(viewParams); </code></pre> <p>Hah, got it.</p> <p>The code is ok, but id of view created in code is -1 or something different. Point is all i had to do is change id of adView:</p> <pre><code>adView.setId(123123); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload