Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding admob to a canvas in a extends View class
    text
    copied!<p>I am trying to implement admob in my app, but i can't get it working.</p> <p>I have a Class A, wich is the main class, it extends activity. I have a Class B, wich is the class that is called when the application start. I have the following piece of code in class A to archive this: </p> <pre><code>B b = new B(this); setContentView(B); </code></pre> <p>In class B i have a canvas with test and bitmaps. i want to put an ad on the canvas with admob, but i can't archive this. Class B:</p> <pre class="lang-java prettyprint-override"><code>private AdView adView; int[] degree = { 90, 180, 270, 360 };// random graden eindposities pijl // int width, height; Random rand = new Random(); Typeface font; Matrix matrix = new Matrix();// degree,x,yaxis Region region;// region die klikbaar is om het pijl te bewegen AlertDialog alertDialog; LinearLayout layout; public YesNo(Context context) { super(context); // TODO Auto-generated constructor stub } @Override public boolean onTouchEvent(MotionEvent event) { //do something } @Override protected void onDraw(Canvas canvas) { //Do something invalidate(); } </code></pre> <p>i have tried to implement admob with this code(among other):</p> <pre class="lang-java prettyprint-override"><code>public void ads() { adView = new AdView((Activity) getContext(), AdSize.BANNER, "xxxxxxxxxxx"); LinearLayout.LayoutParams params; params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); // Create a linear layout LinearLayout layout = new LinearLayout((Activity) getContext()); layout.setOrientation(LinearLayout.VERTICAL); layout.setPadding(6, 6, 6, 6); layout.addView(adView, params); } </code></pre> <p>I searched hours for a solution but i can't find any.</p> <p>Can somebody help me in the right direction?</p>
 

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