Unknown Error in XML - android

Hi i have made this xml file but it is throwing some error : Incorrect line ending: found carriage return (\r) without corresponding newline (\n)
Here is my XML file :
<?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" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/help_new_session"
android:layout_above="#+id/buttonHideNewSessionHelp"
/>
<Button
android:id="#+id/buttonHideNewSessionHelp"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:onClick="onButtonClick"
android:text="Hide" />
</RelativeLayout>
</LinearLayout>

The below process will resolve your issue.
Open layout file
Ctrl+Shift+F
Save the layout file and close it.
Delete any .out files the builder might have created(you can see .out files below the original layout file).
Clean project.

Try this layout Now
<?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" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/help_new_session"
android:layout_above="#+id/buttonHideNewSessionHelp"/>
<Button
android:id="#+id/buttonHideNewSessionHelp"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:onClick="onButtonClick"
android:text="Hide" />
</RelativeLayout>
</LinearLayout>
It is looking perfect

I use the same code of your not giving any problem to me.Select complete xml and use ctrl+i i will align and clean the project once

Related

Cannot resolve symbol R after adding another xml file to my project

As the title say , i was using only one xml file on my project activity_maps ,
and everything was working fine , but after adding info_window.xml , the symbol R became red and i don't know why , i tried rebuilding project and nothing happened.
This is my activity_maps.xml :
<RelativeLayout 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"
tools:context=".MapActivity" >
<fragment 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:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>
This is my info_window.xml :
<?xml version="1.0" encoding="utf-8"?>
<linearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageview1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/sefleticon"/>
<linearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#id/tv_place"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25sp"
android:textStyle="bold" />
<TextView
android:id="#id/tv_men"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#id/tv_women"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#id/tv_like"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</linearLayout>
</linearLayout>
The both of the xml files are in res/layout
Change id="#id" with id="#+id" like this:
<TextView
android:id="#+id/tv_place" <!--add +id-->
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25sp"
android:textStyle="bold" />
edit:
and like Nikhil Verma said, change LinearLayout with upcase on two places.
In your second Xml to :
Change linearLayout to LinearLayout
And in your TextView's change android:id="#id/your_id" to android:id="#+id/your_id"

my list view in android seems like a square how to fix that and what is the error?

I have an android application that uses php and mysql and after fetching the from the database, the result are displayed in a listView that is handled by a BaseAdapter.
The problem is that the rows in the list seem like a square.
can anyone tell me where the mistake is in the xml files ???
activity_user_list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#drawable/background_1">
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/background_1"
android:orientation="vertical" >
<TextView
android:id="#+id/uid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
<TextView
android:id="#+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="text view"
android:textColor="#FFFFFF"
android:textSize="17dip"
android:textStyle="bold" />
<TextView
android:id="#+id/txtCreateDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="TextView"
android:textColor="#FFFFFF" />
</RelativeLayout>
Try removing the background image from activity_user_list.
Try remove the background of your relative layout.

Another r cannot be resolved to a variable/error parsing xml junk after document element

I know this is asked a lot but I got error parsing xml junk after document element problem and then after while of looking for the problem I got 10 r can not be defined errors i think it all resulted from the first error. But even when I remove the problem paragraph and click clean the error red x is still there on a blank area.The error started on the textview line at the bottom.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="25dp" >
<EditText
android:id="#+id/etCommands"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Type a Command"
android:password="true" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >
<Button
android:id="#+id/bResults"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="20"
android:text="Try Command" />
<ToggleButton
android:id="#+id/tbPassword"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="80"
android:checked="true"
android:paddingBottom="10dp"
android:text="ToggleButton" />
</LinearLayout>
<TextView
android:text="invalid"
android:id="#+id/tvResults"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100" />
should be
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >
Notice no / at the end of the tag. The / at the end is xml for "close this tag right now please." As it stands, you have invalid xml with two open tags for LinearLayout but closing LinearLayout 3 times.
It's hard to know what is the problem when you don't provide the full xml file. You probably forgot to close one of your LinearLayout items.
edit:
simply delete the / character from your LinearLayout declaration:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >

Using android developer example 'notepadv3' - how do I add the 'body' value to the Listview?

the code in my notes_row.xml file look like
<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="#+id/text1" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:minWidth="100dp"/>
<TextView android:id="#+id/body" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:minWidth="100dp"
android:fontSize="20dp"/>
I get the following error
The markup in the document following the root element must be well-formed.
at line xmlns:android="http://schemas.android.com/apk/res/android"
I am hoping someone will be able to help me find success.
Note: I found the code that I copied into this question here.
I didn't test it but try this way:
<?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">
<TextView android:id="#+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:minWidth="100dp"/>
<TextView android:id="#+id/body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:minWidth="100dp"
android:fontSize="20dp"/>
</LinearLayout>

error in creating menu.xml of Game Menu

I am designing game menu,I am taking reference of http://p-xr.com/android-tutorial-game-menu-with-a-custom-font/comment-page-1/#comment-857
My main.xml file currently contains:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/wallpaper1" />
<LinearLayout
android:orientation="vertical"
android:layout_margin="10dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:text="START GAME"
android:layout_gravity="right"
android:id="#+id/start"/>
<TextView
android:text="QUICK GAME"
android:id="#+id/quick"/>
<TextView
android:text="SETTINGS"
android:id="#+id/settings"/>
<TextView
android:text="ABOUT"
android:id="#+id/about"/>
<TextView
android:text="EXIT"
android:id="#+id/exit"/>
</LinearLayout>
</RelativeLayout>
However there seems to be an error error, which I do not understand, in graphical layout which says: "You must specify layout_height and layout_width".
AFAIK, attributes android:layout_width and android:layout_height are mandatory for each view declared in a XML layout file.
Just define them for each TextView element.

Categories

Resources