简体   繁体   中英

What is wrong with this XML code?

I got this piece of code from a book viz. "sams teach yourself android application development in 24 hours." This is a layout of a main Menu.

   <TextView 
    xmlns:android=”http://schemas.android.com/apk/res/android” 
    android:layout_width=”fill_parent” 
    android:textSize=”@dimen/menu_item_size” 
    android:text=”test string” 
    android:layout_gravity=”center_horizontal” 
    android:layout_height=”wrap_content” 
    android:shadowRadius=”5” 
    android:gravity=”center” 
    android:textColor=”@color/menu_color” 
    android:shadowColor=”@color/menu_glow” 
    android:shadowDy=”3” 
    android:shadowDx=”3” />

I tried this code in Droid draw. It's showing the error "Open qoute is expected for attribute"{1}" associated with an element type "xmlns:android"". I am very new to Android and Java. Can anybody please tell me how to solve this error? Thanks in advance.(I am sing eclipse in win 7.)

EDIT : I understood. ” this type of quote was creating problem. I replaced with ". But now it is showing "Error no layout". Can anybody check the code please?

Can you post a little more details, perhaps a few lines of the code. I think it is because you may have just copy pasted the code and sometimes the editor would confuse the quote"". Just delete the lines you are getting error in and type it in manually. It may solve the problem. Also check if you have implemented "" properly (open/close). If it doesn't solve it, then it will be easy if you post the code so I can have a look.

Edit: Okay, The problem is the code you are using. Instead of using

xmlns:android=”http://schemas.android.com/apk/res/android” 

Use,

xmlns:android="http://schemas.android.com/apk/res/android" 

Notice the different quote in these two lines. That is the standard quote. Like I said, it happens mainly when you copy paste a code. So, just type it in manually, it will work.

On the second error: Have you created all the @color, @dimen resources that you are referring to?

在我看来,您没有使用标准的双引号字符" ,而是使用了其他内容:

I think your is not correct. It should be " . This could happen when you copy code from a pdf or a website.

Looks like this is a general xml validation error having nothing to do with andriod platform. There may be some extra quote somewhere you need to find and remove.

您是否尝试使用正确的引号:“而不是”?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM