Add an AdMob Ad above a TabbedView? - android

I am getting an "Error parsing XML file: Unbound prefix" when I try to put my AdMob ad reference above a tabbed view. Any ideas how to fix that?
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:padding="5dp">
<com.admob.android.ads.AdView android:id="#+id/ad"
android:layout_width="fill_parent" android:layout_height="wrap_content"
myapp:backgroundColor="#000000" myapp:primaryTextColor="#FFFFFF"
myapp:secondaryTextColor="#CCCCCC" />
<TabWidget android:id="#android:id/tabs"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
<FrameLayout android:id="#android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>

You're using this:
myapp:backgroundColor
but I don't see any declaration of the 'myapp' prefix. so that might be the source of the error.
Just like the "android" namespace is declared in the xml like this:
xmlns:android="http://schemas.android.com/apk/res/android"
the 'myapp' namespace should have a declaration somewhere also

This answer seems related.
You need both the xmlns set correctly, as Nanne said, as well as your attributes defined in res/style/attrs.xml.
The xmlns appears to be:
xmlns:admob="http://schemas.android.com/apk/res/com.example.package"
For an example attrs.xml, check out the answer above.

Related

android:tabStripEnabled="false" doesn't work

I was using tabhost and trying to disable the tab border line. I used this android:tabStripEnabled="false"
in my XML but it doesn't seem to be working, the line was still there, and I try other way like making changes in the style.xml(which I found from stackoverflow) but it doesn't work either. Any idea?
my tab xml:
<?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" >
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#android:id/tabs" />
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#FFFFFF"
android:tabStripEnabled="false"
android:layout_gravity="bottom" />
</RelativeLayout>
</TabHost>
</LinearLayout>
You can remove the bottom strip of tabs and divider between tabs by using following statement.
TabHost t;
t.getTabWidget().setStripEnabled(false);
t.getTabWidget().setDividerDrawable(R.drawable.ic_launcher);
It requires minSDK 8 (2.2) at least... Review your manifest.
Be sure that there insn't a line, in your code, setting tab's background (I had this problem ...) ;)

How can I delete the line below my Tab layout?

I'm sory for my poor Englisch. I come from Holland, and I'm just 14.
I am practicing my android development skills, but I have a problem. If I create a tab menu comes a horizontal line below. With a black background you don't see it, but if it is white you'l see it.
![http://img703.imageshack.us/img703/503/emulator.png][1]
My question is rather simple. How can I delete that line? The XML layoutfile of this tab menu is displayed below.
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>
please try by removing android:padding="5dp" from the FrameLayout.
have you tried xml attributes in here?

AdMob in android "AdView missing required XML attribute 'adSize' "

I am trying to implement AdMob in my Application. But dont know somehow its showing this error and my R.java file is not being generated due to it. I have tried all the ways to solve this problem, like Clean,Build, Build All. But non is working for me.
Following my code snippet in which its showing error "Error in parsing XML: Unbound prefix"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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" android:orientation="vertical"
android:background="#color/bgcolor">
<LinearLayout
android:id="#+id/Linearlayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<com.google.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="XXX"
ads:refreshInterval="60"/>
</LinearLayout>
Please help me out. I am stuck here :(
Probably a namespace issue. You have to define the namespace.
try adding
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
New Admob SDK (Google Play services) requiried another namespace
xmlns:ads="http://schemas.android.com/apk/res-auto"
<?xml version="1.0" encoding="utf-8"?>
<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:id="#+id/rltvLayoutPromote"
android:layout_height="fill_parent">
<LinearLayout android:id="#+id/linearLayoutwebview"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:orientation="vertical">
<WebView android:id="#+id/webViewPromote"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:fitsSystemWindows="true" />
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:id="#+id/ad_layout" android:layout_height="wrap_content"
android:gravity="bottom" android:layout_alignParentBottom="true"
android:layout_alignBottom="#+id/home_layout">
<com.google.ads.AdView android:layout_width="wrap_content"
android:layout_height="wrap_content" ads:adUnitId="XXXXXXXXXX"
ads:adSize="BANNER" android:id="#+id/adView" ads:refreshInterval="60" />
<!-- put 3 if not working-->
</LinearLayout>
</RelativeLayout>
and put this lines in manifest.xml file
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<meta-data android:value="true" android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" />
the above code is working perfectly for me... visit this site for complete reference help forandroid-admobThanks Pragna

Android : "Ignoring unknown 'WebView' XML element" message in Error log

first,sorry for my bad English!!
i'm new here and i'm a beginner of android apps developer! and i have a problem:
it's main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id= "#+id/txtv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/hello"/>
<WebView
android:id="#+id/webv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id = "#+id/backButton"
android:text="#string/bText"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<Button
android:id = "#+id/forwardButton"
android:text="#string/fText"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
>
</LinearLayout>
>
</LinearLayout>
but when i debug my app this error will be shown in ErrorLog window:
AndroidManifest: Ignoring unknown 'WebView' XML element
edit: problem solved and the above code is modified and correct code!!
Remove this part of the code from WebView xmlns:android="http://schemas.android.com/apk/res/android" and add android:layout_width and android:layout_height properties to your buttons.

Tabhost tutorial broken? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Anyone know what this error mean for android tabs?
I have been trying to do the TabHost tutorial in the SDK but for some reason, is appears to break. On Step 4 I copy and paste the xml code, I get an error that prevents it from inflating properly. the error is:
Error in an XML file: aborting build.
This is in the graphical layout of the xml file.
Error during post inflation process:
TabHost requires a TabWidget with id "android:id/tabs",
View found with id "tabs" is 'com.android.layoutlib.bridge.MockView'
The xml file Itself has this in it.
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>
Am I doing something wrong?
Use this template:
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout
android:id="#+id/tab" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">
<TabWidget
android:id="#android:id/tabs" android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:id="#+id/tab1" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical"/>
<LinearLayout android:id="#+id/tab2" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical"/>
</FrameLayout>
</LinearLayout>
</TabHost>
See step 5 , your Activity must extend TabActivity, not Activity
Now open HelloTabWidget.java and make it extend TabActivity:
Switch to android target 3.0 or 3.1 in the graphical layout itself. You can find the drop down list on the top right corner
You can use the updated rendering library found here: Android Tools.
Just extract the directories found in \layoutlib\[platform version] to \[sdk dir]\platforms\[platform version] and let it override the layoutlib.

Categories

Resources