Android 如何调整xml的布局?安卓

Android 如何调整xml的布局?安卓,android,xml,eclipse,adt,android-xmlpullparser,Android,Xml,Eclipse,Adt,Android Xmlpullparser,我有这个xml文件 <Root> <Item ItemNumber="1"> <nd ref='a' /> </Item> <Item ItemNumber="2"> <nd ref='b' /> </Item> <Item ItemNumber="3"> <nd ref='c' /> </I

我有这个xml文件

<Root>
    <Item ItemNumber="1">
         <nd ref='a' />
    </Item>
   <Item ItemNumber="2">
         <nd ref='b' />
    </Item> <Item ItemNumber="3">
         <nd ref='c' />
    </Item> <Item ItemNumber="4">
         <nd ref='d' />
    </Item> <Item ItemNumber="5">
         <nd ref='e' />
    </Item> <Item ItemNumber="6">
         <nd ref='f' />
    </Item>
</Root>
但我想要这样

a
1
--
b
2
--
c
3
--
我已经找过了,找不到它。 你们能帮我吗

下面是MainActivity.java

import java.io.IOException;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import android.os.Bundle;
import android.app.Activity;
import android.app.ListActivity;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.view.Menu;
import android.widget.ArrayAdapter;

public class MainActivity extends ListActivity {

    String item;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        try{
            item = getItemFromXML(this);
        }catch (XmlPullParserException e){
        }catch (IOException e){
        }

        String[] items = item.split("\n");
        setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items));
    }

    public String getItemFromXML(Activity activity) throws XmlPullParserException, IOException{
        StringBuffer stringBuffer = new StringBuffer();
        Resources res = activity.getResources();
        XmlResourceParser xpp = res.getXml(R.xml.items);
        xpp.next();
        int eventType = xpp.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT){
            if (eventType == XmlPullParser.START_TAG){
                if (xpp.getName().equals("Item")){

                    stringBuffer.append(xpp.getAttributeValue(null, "ItemNumber") + "\n");
                }
                if (xpp.getName().equals("nd")){
                    stringBuffer.append(xpp.getAttributeValue(null, "ref") + "\n");
                }

            }
            eventType = xpp.next();
        }
        return stringBuffer.toString();

    }

}
activity_main.xml

<?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">
    <!-- Main ListView 
         Always give id value as list(@android:id/list)
    -->
    <ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>

</LinearLayout>

尝试时,在XmlResourceParser xpp=res.getXmlR.xml.items处出现错误;你能在你的问题中附上这方面的内容吗?
<?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">
    <!-- Main ListView 
         Always give id value as list(@android:id/list)
    -->
    <ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>

</LinearLayout>