d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Xml Error?
Add Reply New Topic New Poll
Member
Posts: 18,191
Joined: May 31 2010
Gold: 149.27
Jun 6 2013 07:46pm
My text view:

Code
<TextView
       android:id="@+id/label"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="Type here:"
       tools:context=".MainActivity" />
       



then this is my whole code

Code
<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:"
       tools:context=".MainActivity" />
       
     

   <EditText
       android:id="@+id/editText1"
       android:layout_width="warp_content"
       android:layout_height="wrap_content"
       android:layout_below="@+id/label"
       android:layout_marginTop="10dip"
       android:ems="10" >

       <requestFocus />
       
   </EditText>

   <Button
       android:id="@+id/button2"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_alignBaseline="@+id/button1"
       android:layout_alignBottom="@+id/button1"
       android:layout_marginLeft="17dp"
       android:layout_toRightOf="@+id/button1"
       android:text="Cancle" />

   <EditText
       android:id="@+id/editText2"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_alignParentLeft="true"
       android:layout_alignParentRight="true"
       android:layout_below="@+id/label"
       android:ems="10" />

   <Button
       android:id="@+id/button1"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_below="@+id/editText2"
       android:layout_marginLeft="24dp"
       android:layout_marginTop="17dp"
       android:layout_toRightOf="@+id/label"
       android:text="OK" />

</RelativeLayout>





and the error it says when i try to run my app is

Description Resource Path Location Type
Element type "TextView" must be followed by either attribute specifications, ">" or "/>". activity_main.xml /LinearLayouts/res/layout line 10 Android XML Format Problem
Description Resource Path Location Type
error: Error parsing XML: not well-formed (invalid token) activity_main.xml /LinearLayouts/res/layout line 10 Android AAPT Problem
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jun 6 2013 09:28pm
try removing the whole textview. if it works, add it with only 1 attribute. keep adding 1 attribute until you find the problem.

btw, your strings really should pull from the string resource. i dont know if : is valid here

This post was edited by carteblanche on Jun 6 2013 09:35pm
Member
Posts: 2,757
Joined: Nov 26 2007
Gold: 1,214.81
Jun 7 2013 07:04am
What is this line for...

tools:context=".MainActivity"

I'm guessing that's what's giving you the error. Delete it and your error should go away
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jun 7 2013 10:36am
Quote (labatymo @ Jun 7 2013 09:04am)
What is this line for...

tools:context=".MainActivity"

I'm guessing that's what's giving you the error. Delete it and your error should go away


i think that's created by the WYSIWYG tool for theming. i always make my xml by hand though
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll