I am having real problems understanding Layouts. I am trying to put admob into my app, but up until this point i have had no reason to use a layout. I’ll show you what I have in my activity class.
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
View tfview = new TFView(this);
setContentView(tfview);}
I then proceed to have the entirety of my application written in Java, without the use of any XML. How to I put both this view and the Admob onto a layout? I tried adding both of them to the layout by doing this:
LinearLayout layout = (LinearLayout)findViewById(R.id.linearLayout);
AdView adView = new AdView(this, AdSize.BANNER, pubID);
layout.addView(adView);
layout.addView(tfview);
AdRequest request = new AdRequest();
request.setTesting(true);
adView.loadAd(request);
but I receive some sort of null pointer exception errors. Can Anybody help?
Thanks in advance
-Derek
Thanks to all of your responses. I eventually just read some other responses to similar questions and built my layout on programatically(if thats a word). So basically I did this:
And it works like a charm. Thanks again to all of you.
-Derek