I have two views (ads) and when one ad network has no ad to show the view is supposed to flip to admob as a backup. The first view is inmobi (not sure if that has any relevance). If I force the inmobi ad to fail by turning test ads on the view will flip and show the admob ad but when live ads are turned on, the view never flips even when the failed ad callback is received. Please help.
@Override
public void adRequestFailed(InMobiAdView arg0) {
// TODO Auto-generated method stub
Log.v("","inmobi ad request failed");
// Initiate a generic request to load it with an ad
loadAdmob();
ViewFlipper vf = (ViewFlipper) findViewById(R.id.ads);
vf.showNext();
}
private void loadAdmob() {
AdView adView = new AdView(this, AdSize.BANNER, "xxxxxxxxxxx");
LinearLayout layout = (LinearLayout) findViewById(R.id.mainLayout);
// Add the adView to it
layout.addView(adView);
adView.loadAd(new AdRequest());
}
And the XML
<ViewFlipper android:id="@+id/ads"
android:layout_width="320dip"
android:layout_height="50dip">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.inmobi.androidsdk.impl.InMobiAdView
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:id = "@+id/adview"
/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_gravity="center"
android:id="@+id/mainLayout" ></LinearLayout>
</ViewFlipper>
I have no see the question yet. But if you need to flip just between Layouts I can provide my own code how to use the flip functionality. First you should create a separate pages of your future Layouts, like page_1.xml in res.layout folder.
After you have done, describe a main.xml file including external xml-pages:
Than don’t forget in class file to declare vf=(ViewFlipper)findViewById(R.id.ViewFlipper01);
Next step you should to override OnTouchEvent to calculate new coordinates and showing the flip-animation:
And the last one – describe an animation methods which mentioned in OnTouchEvent:
Write similar for the rest in/out flip directions.