title: ClassCastException when try to load more on listview
body: <p>I am trying to add a loading icon as a footerView in my listview.
  But when I Scroll and append new data to listview
  I get ClassCastException and my app is close</p>
  
  <p>I get the exception in when LoadMoreXML class was execute</p>
  
  <p>Can anyone help me?</p>
  
  <p>This is my code</p>
  
  <p><strong>Main Fragment</strong></p>
  
  <pre><code>public class LayoutActivity extends Fragment implements OnScrollListener{
  
      ListView listview;
      ListItemAdapter theAdapter;
      ListItemAdapter myExistingAdapter = null;
      String URL = "http://localhost/api/question/get_newest_except/0/0/5";
      ProgressDialog pDialog;
      NodeList nodelist;
      ArrayList&lt;ListItemObject&gt; data;
      Integer counter=0;
  
      public LayoutActivity() {
          super();
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          View rootview = inflater.inflate(R.layout.layout_main, container,false);
          listview = (ListView) rootview.findViewById(R.id.list01);
          ProgressBar spinner = new ProgressBar(this.getActivity());
          listview.addFooterView(spinner);
  
          new DownloadXML().execute(URL);
          listview.setOnScrollListener(this);
          return rootview;
      }
      public class DownloadXML extends AsyncTask&lt;String, Void, Void&gt;{
  
          public DownloadXML() {
              super();
          }
  
          @Override
          protected void onPreExecute() {
  
          }
  
          @Override
          protected void onPostExecute(Void result) {
              // TODO Auto-generated method stub
              data = new ArrayList&lt;ListItemObject&gt;();
              ListItemObject itemData;
  
              try{
                  for (int temp = 0; temp &lt; nodelist.getLength(); temp++) {
                      Node nNode = nodelist.item(temp);
                      if (nNode.getNodeType() == Node.ELEMENT_NODE) {
                          Element eElement = (Element) nNode;
                          itemData = new ListItemObject();
  
                          itemData.setId(getNode("pb__question__id",eElement));
                          itemData.setOwner(getNode("pb__question__consumer__id",eElement));
                          if(!getNode("pb__question__consumer__id",eElement).equalsIgnoreCase("0")){
                              itemData.setName(getNode("pb__question__consumer__name",eElement));
                              itemData.setJob(getNode("pb__question__consumer__occupation", eElement));
                              itemData.setProfilePic(getNode("pb__question__consumer__pp",eElement));
                          }
                          itemData.setStatus(getNode("pb__question__title",eElement));
                          itemData.setExtras(getNode("pb__question__topic__name", eElement));
                          if(!getNode("att__pict",eElement).isEmpty()){
                              itemData.setImage(getNode("att__pict", eElement));
                          }
  
                          if(getNode("pb__question__type", eElement).equalsIgnoreCase("1")){
                              itemData.setOpini(getNode("pb__question__total__opini", eElement));
                          }else if(getNode("pb__question__type", eElement).equalsIgnoreCase("2") || getNode("pb__question__type", eElement).equalsIgnoreCase("3")){
                              itemData.setOpini(getNode("pb__question__total__polling", eElement));
                          }else if(getNode("pb__question__type", eElement).equalsIgnoreCase("4")){
                              itemData.setOpini(getNode("pb__question__total__rating", eElement));
                          }
  
                          itemData.setTipe(getNode("pb__question__type", eElement));
                          itemData.setIkuti(getNode("pb__question__total__follow", eElement));
                          itemData.setSebarkan(getNode("pb__question__total__share", eElement));
  
                          data.add(itemData);
                      }
                  }
                  theAdapter = new ListItemAdapter(LayoutActivity.this.getActivity(),data);
                  listview.setAdapter(theAdapter);
  
              }catch(Exception e){
                  Toast.makeText(getActivity(), "Koneksi dengan server gagal" , Toast.LENGTH_SHORT).show();
              }
  
          }
  
          @Override
          protected Void doInBackground(String... Url) {
              try {
                  URL url = new URL(Url[0]);
                  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                  DocumentBuilder db = dbf.newDocumentBuilder();
                  Document doc = db.parse(new InputSource(url.openStream()));
                  doc.getDocumentElement().normalize();
                  nodelist = doc.getElementsByTagName("pb__question");
  
              } catch (Exception e) {
                  Log.e("Error", e.getMessage());
                  e.printStackTrace();
              }
              return null;
          }
  
      }
  
      public class LoadMoreXML extends AsyncTask&lt;String, Void, Void&gt;{
          ArrayList&lt;ListItemObject&gt; data;
  
          public LoadMoreXML() {
              super();
          }
  
          @Override
          protected void onPreExecute() {
  
          }
  
          @Override
          protected void onPostExecute(Void result) {
              // TODO Auto-generated method stub
              data = new ArrayList&lt;ListItemObject&gt;();
              ListItemObject itemData;
                  for (int temp = 0; temp &lt; nodelist.getLength(); temp++) {
                      Node nNode = nodelist.item(temp);
                      if (nNode.getNodeType() == Node.ELEMENT_NODE) {
                          Element eElement = (Element) nNode;
                          itemData = new ListItemObject();
  
                          itemData.setId(getNode("pb__question__id",eElement));
                          itemData.setOwner(getNode("pb__question__consumer__id",eElement));
                          if(!getNode("pb__question__consumer__id",eElement).equalsIgnoreCase("0")){
                              itemData.setName(getNode("pb__question__consumer__name",eElement));
                              itemData.setJob(getNode("pb__question__consumer__occupation", eElement));
                              itemData.setProfilePic(getNode("pb__question__consumer__pp",eElement));
                          }
                          itemData.setStatus(getNode("pb__question__title",eElement));
                          itemData.setExtras(getNode("pb__question__topic__name", eElement));
                          if(!getNode("att__pict",eElement).isEmpty()){
                              itemData.setImage(getNode("att__pict", eElement));
                          }
  
                          if(getNode("pb__question__type", eElement).equalsIgnoreCase("1")){
                              itemData.setOpini(getNode("pb__question__total__opini", eElement));
                          }else if(getNode("pb__question__type", eElement).equalsIgnoreCase("2") || getNode("pb__question__type", eElement).equalsIgnoreCase("3")){
                              itemData.setOpini(getNode("pb__question__total__polling", eElement));
                          }else if(getNode("pb__question__type", eElement).equalsIgnoreCase("4")){
                              itemData.setOpini(getNode("pb__question__total__rating", eElement));
                          }
  
                          itemData.setTipe(getNode("pb__question__type", eElement));
                          itemData.setIkuti(getNode("pb__question__total__follow", eElement));
                          itemData.setSebarkan(getNode("pb__question__total__share", eElement));
  
                          data.add(itemData);
                      }
                  }
  
                  myExistingAdapter = (ListItemAdapter) listview.getAdapter();
                  myExistingAdapter.addItems(data);
          }
  
          @Override
          protected Void doInBackground(String... Url) {
              try {
                  URL url = new URL(Url[0]);
                  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                  DocumentBuilder db = dbf.newDocumentBuilder();
                  Document doc = db.parse(new InputSource(url.openStream()));
                  doc.getDocumentElement().normalize();
                  nodelist = doc.getElementsByTagName("pb__question");
  
              } catch (Exception e) {
                  Log.e("Error", e.getMessage());
                  e.printStackTrace();
              }
              return null;
          }
  
      }
  
      private static String getNode(String sTag, Element eElement) {
          NodeList nlList = eElement.getElementsByTagName(sTag).item(0).getChildNodes();
          Node nValue = (Node) nlList.item(0);
          String result = "";
          if(nValue!=null){
              result = nValue.getNodeValue();
          }
          return result;
      }
  
      @Override
      public void onScroll(AbsListView view, int firstVisibleItem,
              int visibleItemCount, int totalItemCount) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void onScrollStateChanged(AbsListView view, int scrollState) {
          // TODO Auto-generated method stub
          int threshold = 2;
          int count = listview.getCount();
          if(scrollState == SCROLL_STATE_IDLE){
  
              if(listview.getLastVisiblePosition() &gt;= count - threshold){
                  counter+=5;
                  new LoadMoreXML().execute("http://localhost/api/question/get_newest_except/0/"+counter+"/5");
              }
          }
      }
  }
  </code></pre>
  
  <p>And this is the error <strong>Log</strong></p>
  
  <p><img src="https://i.stack.imgur.com/2YDwh.jpg" alt="enter image description here"></p>
  
  <p>Thank you</p>