Xml error help


Last Updated:

  1. matio

    matio New Member This Topic's Starter

    Joined:
    Apr 15, 2010
    Messages:
    1
    Likes Received:
    0
    Hi everyone, I'm trying to develop a todo app with the android sdk and eclipse, so far I've got a list view and I am able to create, edit and delete todo items. The problem I'm having is with the xml file that defines a row in the list view:
    PHP:
    1.  
    2. <?xml version="1.0" encoding="utf-8"?>
    3.  
    4. <TextView
    5.     android:id="@+id/text1"
    6.     android:layout_width="wrap_content"
    7.     android:layout_height="wrap_content"
    8.     xmlns:android="http://schemas.android.com/apk/res/android">
    9. </TextView>
    10.  
    11. <TextView
    12.     android:id="@+id/text2"
    13.     android:layout_width="wrap_content"
    14.     android:layout_height="wrap_content"
    15.     xmlns:android="http://schemas.android.com/apk/res/android">
    16. </TextView>
    17.  
    Eclipse flags the second TextView with this:
    Code (Text):
    1.  
    2. Multiple annotations found at this line:
    3.     - error: Error parsing XML: junk after document element
    4.     - The markup in the document following the root element must be well-
    5.      formed.
    6.  

    It's used in this code:
    PHP:
    1.  
    2.     private void getData() {
    3.         mCursor = mDb.fetchAllItems();
    4.         startManagingCursor(mCursor);
    5.  
    6.         String[] cols = new String[]{ ListDbAdapter.DB_ITEM, ListDbAdapter.DB_PRI };
    7.         int[] views   = new int[]{ R.id.text1, R.id.text2 };
    8.         SimpleCursorAdapter row_cursor =
    9.             new SimpleCursorAdapter(this, R.layout.list_row, mCursor, cols,
    10.                     views);
    11.         setListAdapter(row_cursor);
    12.     }
    13.  
    14.  
    15. // --- db handle
    16.     public Cursor fetchAllItems() {
    17.         return listDb.query(DB_TABLE, new String[] {DB_ROWID, DB_ITEM, DB_PRI},
    18.                 null, null, null, null, null);
    19.     }
    20.  
    Can anybody tell me what I'm doing wrong?
     

    Attached Files:


    Advertisement
  2. dmitriyk

    dmitriyk Active Member

    Joined:
    Apr 17, 2010
    Messages:
    44
    Likes Received:
    10
    You've got to have one element at the root of the XML file. Put both TextViews inside a LinearLayout or something.
     

Share This Page

Loading...