2012-04-04 23 views
0

私のサンプルアプリケーションでホイールビューを使用しています。 xml解析を使用して項目を表示します。 そのxmlデータに1つの項目を追加したいと思います。ここに私のコードもう1つのアイテムを追加するにはどうすればいいのですか?アンドロイドのarraylist

public ArrayList<ItemIdentifierType> getBikeTypeDataList() { 

    NodeList nodeList = doc.getElementsByTagName(key_BikeTypes); 

    for (int i = 0; i < nodeList.getLength(); i++) { 

     ItemIdentifierType itemIdentifierTypeInstance = new ItemIdentifierType(); 
     Element element = (Element) nodeList.item(i); 
     itemIdentifierTypeInstance.setId(Integer.parseInt(element 
       .getAttribute("id"))); 
     itemIdentifierTypeInstance.setName(element.getAttribute("desc"));   

     bikeTypesList.add(itemIdentifierTypeInstance); 

    } 

    return bikeTypesList; 
} 

ここbikeTypeList私はbikeTypesListの中で-select-のような1つの項目を追加したいと思っています。誰でも私を助けることができますか?

答えて

1

今その作業罰金、ここに私のコード

public ArrayList<ItemIdentifierType> getBikeTypeDataList() { 

    NodeList nodeList = doc.getElementsByTagName(key_BikeTypes); 
    ItemIdentifierType itemIdentifierTypeInstance = null ; 
    itemIdentifierTypeInstance = new ItemIdentifierType(); 
    itemIdentifierTypeInstance.setId(0); 
    itemIdentifierTypeInstance.setName("-beliebig-");  
    Log.i("bike typeLsit: ", "" 
      + itemIdentifierTypeInstance.getId() + " " 
      + itemIdentifierTypeInstance.getName());    
    bikeTypesList.add(itemIdentifierTypeInstance); 
    for (int i = 0; i < nodeList.getLength(); i++) { 

     itemIdentifierTypeInstance = new ItemIdentifierType(); 
     Element element = (Element) nodeList.item(i); 
     itemIdentifierTypeInstance.setId(Integer.parseInt(element 
       .getAttribute("id"))); 
     itemIdentifierTypeInstance.setName(element.getAttribute("desc")); 

     Log.i("bike details from identifier type class: ", "" 
       + itemIdentifierTypeInstance.getId() + " " 
       + itemIdentifierTypeInstance.getName());    
     bikeTypesList.add(itemIdentifierTypeInstance);  

    }   
    System.out.println("TypeList"+bikeTypesList); 
    return bikeTypesList; 
} 
関連する問題