title: How to adjust layout of xml? android
body: <p>I have this xml file </p>
  
  <pre><code>&lt;Root&gt;
      &lt;Item ItemNumber="1"&gt;
           &lt;nd ref='a' /&gt;
      &lt;/Item&gt;
     &lt;Item ItemNumber="2"&gt;
           &lt;nd ref='b' /&gt;
      &lt;/Item&gt; &lt;Item ItemNumber="3"&gt;
           &lt;nd ref='c' /&gt;
      &lt;/Item&gt; &lt;Item ItemNumber="4"&gt;
           &lt;nd ref='d' /&gt;
      &lt;/Item&gt; &lt;Item ItemNumber="5"&gt;
           &lt;nd ref='e' /&gt;
      &lt;/Item&gt; &lt;Item ItemNumber="6"&gt;
           &lt;nd ref='f' /&gt;
      &lt;/Item&gt;
  &lt;/Root&gt;
  </code></pre>
  
  <p>I want to display it in a listview but when i do that the nd node goes into another line</p>
  
  <p>for example</p>
  
  <pre><code>a
  --
  1
  --
  b
  --
  2
  --
  c
  --
  3
  --
  </code></pre>
  
  <p>but i want it like this</p>
  
  <pre><code>a
  1
  --
  b
  2
  --
  c
  3
  --
  </code></pre>
  
  <p>I have searched about this and i cant get it.
  Can you guys help me with this.</p>
  
  <p>here is the MainActivity.java</p>
  
  <pre><code>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&lt;String&gt;(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();
  
      }
  
  }
  </code></pre>
  
  <p>activity_main.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical"&gt;
      &lt;!-- Main ListView 
           Always give id value as list(@android:id/list)
      --&gt;
      &lt;ListView
          android:id="@android:id/list"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>