Hi I'm following this Simple Parse Messaging App tutorial-https://github.com/codepath/android_guides/wiki/Building-Simple-Chat-Client-with-Parse
And I'm getting an error on this line of code:
tools:context="${relativePackage}.${activityClass}"
This is the whole file:
<?xml version="1.0" encoding="utf-8"?>
<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="${relativePackage}.${activityClass}" >
<EditText
android:id="#+id/etMessage"
android:layout_toLeftOf="#+id/btSend"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/btSend"
android:gravity="top"
android:hint="contribute..."
android:imeOptions="actionSend"/>
<Button
android:id="#+id/btSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|right"
android:paddingRight="10dp"
android:layout_alignParentRight="true"
android:text="send"
android:textSize="18sp" >
</Button>
</RelativeLayout>
Replace ${relativePackage} with your package name and replace ${activityClass} with your class name.
For example:
tools:context="whatever.your.package.name.ChatActivity"
I think the tutorial means you should populate relativePackage and activityClass yourself. tools:context must refer to a specific Activity, e.g. com.example.MainActivity.
Related
Multiple annotations found at this line: - error: Error parsing XML: junk after document element The markup in the document following the root element must be well-formed.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.onyourcar.MainActivity"
tools:ignore="MergeRootFrame" />
<TextView
android:id="#+id/hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/hello_world"
tools:context=".MainActivity" />
A default texview is like so
<TextView
android:id="#+id/theTextViewIdHere"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
And try to use a relative/linear layout
<?xml version="1.0" encoding="utf-8"?>
<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" >
<TextView
android:id="#+id/hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/hello_world" />
</RelativeLayout>
If you would like to use FrameLayout hit google for example code
My first guess at your problem was the last line of 'tools:context' try removing that line. In case this does not work post your entire XML file.
Hope this will help.
I had created an old android project called LinearLayouts and written some code in activity_main.xml under the layout folder. The code ran perfectly fine on the emulator. But now I have edited activity_main.xml and changed the code. The problem is that edited or changed code is not shown on the emulator. Could anybody help me to find solution to this problem. Below is the old code and new code in activity_main.xml. When I run the new code even then the emulator shows the old code output. The new code or edited code output is not shown instead of that it shows the old code output itself.
My previous code of activity_main.xml is:
<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">
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Type Here:"
/>
<EditText
android:id="#+id/edittext1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/label"
android:layout_marginTop="10dp"
android:ems="10" >
<requestFocus />
</EditText>
</RelativeLayout>
My new or edited code in activity_main.xml is:
<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"
>
<SlidingDrawer
android:id="#+id/slidingDrawer1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:content="#+id/content"
android:handle="#+id/handle" >
<Button
android:id="#+id/handle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Handle" />
<LinearLayout
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</SlidingDrawer>
</RelativeLayout>
Remove all the files from your /bin folder (except for AndroidManifest.xml) in your project root and try again.
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
This is my code:
<?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:orientation="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";
</EditText>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send";
</Button>
</LinearLayout>
There's an error
at the first EditText and first Button lines, the first error being the one in the title, and the second one being:
'Element type 'EditText' must be followed by either Attribute Specifications, '>' or '/>'
What's wrong? the whole code is made (almost) exactly as shown here http://developer.android.com/training/basics/firstapp/building-ui.html
(and i'm sorry if I misspelled or forgot anything, I'm a noob here...)
EDIT: Thanks, guys, but I tried pasting your code over mine. Though there are no X signs, the debug tool still says there are some errors...
EDIT: Yes, I have the needed strings, as I followed the tutorial. But I don't understand... If I paste the code given on the tutorial's site to Eclipse, there's still an error! I'll try opening the .xml in another program.
You must close your tags either with /> in <EditText key="value" /> or with >in <EditText key="value"></EditText>. Don't use ;
<?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:orientation="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" >
</EditText>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send" />
</LinearLayout>
Edit: After that, if you still have errors, remove:
android:hint="#string/edit_message"
and
android:text="#string/button_send"
unless you have corresponding entries inside your values/strings.xml file for them:
<string name="edit_message">Enter a text</string>
<string name="button_send">Button text</string>
Here's how it should look (notice ending "<" symbols and absence of ";")
<?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="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"
</EditText>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/button_send"
</Button>
</LinearLayout>
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>