How to include layout programmatically in android without using xml layouts to display banner ads in android. I am creating a game App where i need to display banner ads in each and every game page. I have already included full screen revmob ads but i need to include banner ads. I used the following code but banner ads are not displaying
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout android:id="@+id/banner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</LinearLayout>
</LinearLayout>
MainActivity.java
public class MainActivity extends Activity {
private CCGLSurfaceView mGLSurfaceView;
private boolean isCreated = false;
public static FrameLayout m_rootLayout;
public static String APPLICATION_ID = "514b9c57cce0500d00000001";
public static RevMob revmob;
// This is used to display Toast messages and is not necessary for your app
@Override
protected void onCreate(Bundle savedInstanceState) {
if (!isCreated) {
isCreated = true;
} else {
return;
}
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
//admob widget
revmob = RevMob.start(this, APPLICATION_ID);
displayRevMob();
mGLSurfaceView = new CCGLSurfaceView(this);
setContentView(mGLSurfaceView);
CCDirector.sharedDirector().attachInView(mGLSurfaceView);
getScaledCoordinate();
Global.assetManager = getAssets();
Global.context = this;
Global.loadUserInfo();
CCScene scene = CCScene.node();
scene.addChild(new SplashScene(), -1);
CCDirector.sharedDirector().runWithScene(scene);
//-------------IAP-----------------------
Log.d(TAG1, "Creating IAB helper.");
mHelper = new IabHelper(this, base64EncodedPublicKey);
mHelper.enableDebugLogging(true);
Log.d(TAG1, "Starting setup.");
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
Log.d(TAG, "Setup finished.");
if (!result.isSuccess()) {
// Oh noes, there was a problem.
complain("Problem setting up in-app billing: " + result);
return;
}
// Hooray, IAB is fully set up. Now, let's get an inventory of stuff we own.
Log.d(TAG, "Setup successful. Querying inventory.");
mHelper.queryInventoryAsync(mGotInventoryListener);
}
});
RevMobBanner banner = revmob.createBanner(this);
ViewGroup view = (ViewGroup) findViewById(R.id.banner);
view.addView(banner);
Global.myActivity=this;
}