Error parsing XML: unbound prefix Admob - java

I got a problem in my layout where Im trying to add the Admob.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads ="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background="#drawable/lined2"
tools:context=".MainActivity" >
<com.google.ads.AdView
android:id ="#+id/adview"
android:layout_width="fillparent"
android:layout_height="wrap_content"
ads:adUnitId="My ID"
ad:adSize="BANNER"
ads:testdevices="TEST_EMULATOR"
ads:loadAdOnCreate="true" />
So the Error is in this line :
<com.google.ads.AdView
It says :
Error parsing XML:unbound prefix
I really searched many Posts but no one helped me...
I allready add the line with add xmlns:ads .... but It doesnt help :/
Did I forgot sth. ?
Thank you for your help !

You missed s in the namespace for adSize.
Change
ad:adSize="BANNER"
to
ads:adSize="BANNER"

<com.google.ads.AdView
android:id ="#+id/adview"
android:layout_width="fillparent"
android:layout_height="wrap_content"
ads:adUnitId="My ID"
**ads:adSize="BANNER"**
ads:testdevices="TEST_EMULATOR"
ads:loadAdOnCreate="true" />
correction.

Related

Android: Adding a VectorDrawable to an ImageView

So, I wanted to make a scroll-able worldmap with clickable countries. So when I found out there was a thing like VectorDrawables, I decided to give these a try.
Next thing I did was making a VectorDrawable xml file out of a SVG and tried to put it in my ImageView. While searching for some info, I found out that there were 101 ways to do this, and none of them worked for me...
The interesting thing is that, when I add "android:src="#raw/worldmap" in the ImageView in my activity.xml, the map shows up in the preview, but whenever I try to run the app, it crashes.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:id="#+id/activity_show_hint"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.bert.myapplication.ShowHintActivity"
android:weightSum="1">
<ImageView
android:id="#+id/img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:scaleType="center"
android:src="#raw/worldmap">
</ImageView>
</LinearLayout>
First, move your VectorDrawable to Drawable folder (not in raw). and then, add this line in your Gradle file :
defaultConfig{
vectorDrawables.useSupportLibrary = true
}
And finally, in your imageView, change to this;
<ImageView
android:id="#+id/img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:scaleType="center"
app:srcCompat="#drawable/worldmap">
</ImageView>

Android xml error multiple root

So i have this XML and its giving me an error "Multiple root" on the bold. I am copying this example from a book with the purpose to instantiate the MovieLinks fragment ( which will show on a list some movie names) , right after the activity loads the layout. When the user clicks on a item from the list, the application will initiate another activity associated to a second fragment. Can you guys show me what am i doing wrong ? Thanks in advance!!
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<fragment class = "pdm.isel.pt.tmdbapp.MovieLinksFragments"
android:id="#+id/links" android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
**<LinearLayout>**
<fragment class = "pdm.isel.pt.tmdbapp.MovieLinksFragments"
android:id="#+id/links" android:layout_weight="1"
android:layout_width="0px" android:layout_height="match_parent" />
<FrameLayout android:id="#+id/details" android:layout_weight="1"
android:layout_width="0px" android:layout_height="match_parent" />
</LinearLayout>
This and this SO links talk about this issue.
If you move the LinearLayout tag inside FrameLayout that will get rid of your issue at hand. I changed the xml you posted to make it compile, but you need to revisit your book to copy the correct xml. This does not seem alright to me.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<fragment class = "pdm.isel.pt.tmdbapp.MovieLinksFragments"
android:id="#+id/links" android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout android:layout_height="wrap_content" android:layout_width="wrap_content">
<fragment class = "pdm.isel.pt.tmdbapp.MovieLinksFragments"
android:id="#+id/links1" android:layout_weight="1"
android:layout_width="0px" android:layout_height="match_parent" />
<FrameLayout android:id="#+id/details" android:layout_weight="1"
android:layout_width="0px" android:layout_height="match_parent" />
</LinearLayout>
</FrameLayout>

Changing xml or layout during runtime

on my Android project I need to change the color of a xml property: app:footerColor="#1573D6" dynamically during runtime. How can I achieve this?
I could change the layout too during the running of the App, but I looked for how to do it and couldn't find anything.
Some help would be great. Thank you very much.
Here's my xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.viewpagerindicator.TitlePageIndicator
android:id="#+id/tabloid"
android:padding="10dip"
android:layout_height="40dp"
android:layout_width="fill_parent"
android:background="#000000"
android:textColor="#1573D6"
app:footerColor="#1573D6"
app:footerLineHeight="2dp"
app:footerIndicatorStyle="none"
app:selectedColor="#FFFFFF"
app:selectedBold="true" />
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" />
you can do this in code:
TitlePageIndicator indicator =(TitlePageIndicator)findViewById(R.id.yourview)
indicator.SetFooterColor(Color.parse( #1573D6))

No resource identifier found for attribute 'orientaton' in package 'android' activity_main.xml

I encountered this error while debugging my "hello world" App as found in the Get Started Android Development tutorial. Here is my full activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientaton="horizontal">
<EditText android:id="#+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="#string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send" />
I really need some help with this one considering I believe it is keystroke for keystroke as it appears in the tutorial.
You misspelled orientation - orientat i on, not orientaton.

Button overlaps the textview

I am just beginning android programming. Facing an error.
Problem is that the button covers the text in the textview.
I tried to put android:orientation="vertical".........but this android:orientation is not present in the xml...i mean it is not showing in the methods suggested.........Please help me hot to resolve the problem.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".StartingPoint" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world"
android:textSize="45sp"
android:gravity="center"
/>
<Button
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="Add one" />
This is because you are using a relative layout and haven't specified what the button is relative to. I would recommend changing to a different layout (ie linear layout). There is a good tutorial here: http://developer.android.com/guide/topics/ui/declaring-layout.html

Categories