how to add one more item to already exist arraylist in android

Go To StackoverFlow.com

0

i am using wheel view in my sample application. It display the items using xml parsing. i want to add one item to that xml data. here my code

  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;
}

here bikeTypeList have all the items just i want to add one item like -select- within bikeTypesList. any one can help me?

2012-04-04 08:33
by selva


1

now its working fine, here my code

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;
}
2012-04-05 07:01
by selva
Ads