Reputation: 998
I'm reading Android App Development for Dummies by Michael Burton, and working through the book while creating an application.
In setting up the layout of the application I ran into something that stuck me as odd. Here's what the book says on page 68:
"When you're on the Text tab [of activity_main.xml], delete the XML and replace it with the following."
<?xml version="1.0" encoding= encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
Is there a rationale for the double encoding in the aforementioned printing:
<?xml version="1.0" encoding= encoding="utf-8"?>
...
Or is this a misprint? I've looked at other sources and seen
<?xml version="1.0" encoding="utf-8"?>
...
Yet I'm unclear on whether the code in the book is written this way for a reason I don't yet understand.
Upvotes: 0
Views: 799
Reputation: 1568
This is called the "XML declaration" line. Technically it is optional, but it should be there, even if just for the benefit of text editors etc. that can use the encoding attribute when displaying the file.
<?xml version="1.0" encoding="utf-8"?> Correct
These are some other examples of xml headers, that you can experiment with or study about :
<?xml version="1.0" encoding="us-ascii"?>
<?xml version="1.0" encoding="windows-1252"?>
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml version="1.0" encoding="UTF-16"?>
Now Replace this
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
Upvotes: 1