Error parsing XML!

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Error parsing XML!

Postby phannguyen » Tue Oct 14, 2008 9:22 am

hi all,
i copy these codes from http://code.google.com/android/referenc ... wable.html

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <animation-list android:id="selected" android:oneshot="false">
  2.  
  3.     <item android:drawable="@drawable/wheel0" android:duration="50" />
  4.  
  5.     <item android:drawable="@drawable/wheel1" android:duration="50" />
  6.  
  7.     <item android:drawable="@drawable/wheel2" android:duration="50" />
  8.  
  9.     <item android:drawable="@drawable/wheel3" android:duration="50" />
  10.  
  11.     <item android:drawable="@drawable/wheel4" android:duration="50" />
  12.  
  13.     <item android:drawable="@drawable/wheel5" android:duration="50" />
  14.  
  15.  </animation-list>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


but i dont know why i got a error like this "ERROR Error parsing XML: unbound prefix".
please help me.thanks a lot.
PhanNguyen
phannguyen
Experienced Developer
Experienced Developer
 
Posts: 56
Joined: Thu Jul 17, 2008 7:37 am

Top

Postby MrSnowflake » Tue Oct 14, 2008 9:36 am

Do you have the
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
Parsed in 0.000 seconds, using GeSHi 1.0.8.4

and add this to the first tag:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  xmlns:android="http://schemas.android.com/apk/res/android"
Parsed in 0.000 seconds, using GeSHi 1.0.8.4

So the complete xml becomes:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:id="selected" android:oneshot="false">
  5.  
  6.     <item android:drawable="@drawable/wheel0" android:duration="50" />
  7.  
  8.     <item android:drawable="@drawable/wheel1" android:duration="50" />
  9.  
  10.     <item android:drawable="@drawable/wheel2" android:duration="50" />
  11.  
  12.     <item android:drawable="@drawable/wheel3" android:duration="50" />
  13.  
  14.     <item android:drawable="@drawable/wheel4" android:duration="50" />
  15.  
  16.     <item android:drawable="@drawable/wheel5" android:duration="50" />
  17.  
  18.  </animation-list>
  19.  
  20.  
Parsed in 0.003 seconds, using GeSHi 1.0.8.4
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby pwhisler » Sat Nov 08, 2008 8:37 pm

In attempting the same example, I get the error:

Error string types not allowed at 'id' with value 'selectable' android

on this code:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:id= "selectable" android:oneshot="false">
  4.  
  5.     <item android:drawable="@drawable/female_duck0001" android:duration="50" />
  6.  
  7.     <item android:drawable="@drawable/female_duck0002" android:duration="50" />
  8.  
  9.     <item android:drawable="@drawable/female_duck0003" android:duration="50" />
  10.  
  11.     <item android:drawable="@drawable/female_duck0004" android:duration="50" />
  12.  
  13.     <item android:drawable="@drawable/female_duck0005" android:duration="50" />
  14.  
  15.     <item android:drawable="@drawable/female_duck0006" android:duration="50" />
  16.  
  17.  </animation-list>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


if I delete the
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. android:id= "selectable"
Parsed in 0.000 seconds, using GeSHi 1.0.8.4
then I don't get an error, but then I won't be able to access the code in Java right? cuz that is what it seems now, anyone know what to do?

thanks
pwhisler
Junior Developer
Junior Developer
 
Posts: 12
Joined: Sat Nov 08, 2008 8:32 pm

Postby MrSnowflake » Sun Nov 09, 2008 11:46 am

Ow, yeah the
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. android:id="selectable"
Parsed in 0.000 seconds, using GeSHi 1.0.8.4
is the problem it should be:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. android:id="@+id/selectable"
Parsed in 0.000 seconds, using GeSHi 1.0.8.4
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby pwhisler » Mon Nov 10, 2008 3:31 am

I am then using the suggested

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. // Load the ImageView that will host the animation and
  2.  
  3.  // set its background to our AnimationDrawable XML resource.
  4.  
  5.  ImageView img = (ImageView)findViewById(R.id.spinning_wheel_image);
  6.  
  7.  img.setBackgroundResource(R.drawable.spin_animation);
  8.  
  9.  
  10.  
  11.  // Get the background, which has been compiled to an AnimationDrawable object.
  12.  
  13.  AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
  14.  
  15.  
  16.  
  17.  // Start the animation (looped playback by default).
  18.  
  19.  frameAnimation.start()
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


it compiles, but when I run it, it crashes, if i just the leave the first line, its ok, but the second line, the

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  img.setBackgroundResource(R.drawable.spin_animation);
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


it crashes...
pwhisler
Junior Developer
Junior Developer
 
Posts: 12
Joined: Sat Nov 08, 2008 8:32 pm

Postby pwhisler » Tue Nov 11, 2008 8:59 pm

pwhisler
Junior Developer
Junior Developer
 
Posts: 12
Joined: Sat Nov 08, 2008 8:32 pm

Top

Postby MrSnowflake » Wed Nov 12, 2008 8:44 am

Did you setContentView()? Otherwise your R.id.spinning_wheel_image doesn't exist in you layout xml.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby pwhisler » Wed Nov 12, 2008 9:10 am

yes, I used the setContentView(); I have a layout view xml file in the res/layouts folder and i have the animationlist xml file along with all the images in the animation in the res/drawable folder.

I can set the content view to the layout view like this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setContentView(R.layout.main);
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


or I can set it to the panel/view with this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setContentView(mPanel,new ViewGroup.LayoutParams(320,480));
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


where mPanel is a type of class Panel, which extends a View, but in either I don't see the animating image view.

is there something else I should be setting it to?
thanks for you help!
pwhisler
Junior Developer
Junior Developer
 
Posts: 12
Joined: Sat Nov 08, 2008 8:32 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 7 guests