title: Issue with Retrofit and Simple - attempt at making a RSS Reader for Android
body: <p>I'm trying to download XML data with Retrofit and parse it with Simple and then load it into a ListView.</p>
  
  <p>Unfortunately downloaded data won't appear on screen. Could someone tell me where is the problem, please?</p>
  
  <p>This is my model:</p>
  
  <pre><code>@Root(name = "item")
  public class Article {
      @Element(name = "title")
      private String title;
      @Element(name = "author")
      private String author;
      @Element(name = "description")
      private String description;
  </code></pre>
  
  <p>The code for interface:</p>
  
  <pre><code>public interface Service {
      @GET("/rss/news")
      public void getArticle(Callback&lt;List&lt;Article&gt;&gt; callback);
  }
  </code></pre>
  
  <p>The code for fragment:</p>
  
  <pre><code>public class ArticlePreviewFragment extends Fragment {
  
      protected ArticlePreviewAdapter adapter;
      protected List&lt;Article&gt; previewList;
      private ListView listView;
  
      public ArticlePreviewFragment() {}
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          previewList = new ArrayList&lt;&gt;();
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.fragment_article_preview, container, false);
          listView = (ListView) view.findViewById(R.id.previewList);
          return view;
      }
  
      @Override
      public void onActivityCreated(Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
          adapter = new ArticlePreviewAdapter(getActivity(), previewList);
          listView.setAdapter(adapter);
  
          RestAdapter restAdapter = new RestAdapter.Builder()
                  .setLogLevel(RestAdapter.LogLevel.FULL)
                  .setEndpoint("http://muse.mu")
                  .setConverter(new SimpleXMLConverter())
                  .build();
  
          Service service = restAdapter.create(Service.class);
  
          Callback&lt;List&lt;Article&gt;&gt; callback = new Callback&lt;List&lt;Article&gt;&gt;() {
              @Override
              public void success(List&lt;Article&gt; articles, Response response) {
                  adapter.clear();
                  adapter.addAll(articles);
                  adapter.notifyDataSetChanged();
              }
  
              @Override
              public void failure(RetrofitError error)
          };
          service.getArticle(callback);
      }
  }
  </code></pre>
  
  <p>I'm using the converter found here - I've copied it into my project <a href="https://github.com/square/retrofit/blob/master/retrofit-converters/simplexml/src/main/java/retrofit/converter/SimpleXMLConverter.java" rel="nofollow">retrofit/converter/SimpleXMLConverter.java</a></p>
  
  <p>Lastly, the code for adapter:</p>
  
  <pre><code>public class ArticlePreviewAdapter extends ArrayAdapter&lt;Article&gt; {
      List&lt;Article&gt; articlePreviewItems;
      public ArticlePreviewAdapter(Activity activity, List&lt;Article&gt; articlePreviewItems) {
          super(activity, R.layout.item_article_preview, articlePreviewItems);
          this.articlePreviewItems = articlePreviewItems;
      }
  
      private static class ViewHolder {
          TextView articlePreviewTitle;
          TextView articlePreviewAuthor;
          TextView articlePreviewDescription;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          ViewHolder viewHolder;
          Article articlePreviewItem = getItem(position);
  
          if (convertView == null) {
              viewHolder = new ViewHolder();
              LayoutInflater inflater = LayoutInflater.from(getContext());
              convertView = inflater.inflate(R.layout.item_article_preview, parent, false);
              viewHolder.articlePreviewTitle = (TextView) convertView.findViewById(R.id.articleTitle);
              viewHolder.articlePreviewAuthor = (TextView) convertView.findViewById(R.id.articleAuthor);
              viewHolder.articlePreviewDescription = (TextView) convertView.findViewById(R.id.articleDescription);
              convertView.setTag(viewHolder);
          } else {
              viewHolder = (ViewHolder) convertView.getTag();
          }
  
          viewHolder.articlePreviewTitle.setText(articlePreviewItem.getTitle());
          viewHolder.articlePreviewAuthor.setText(articlePreviewItem.getAuthor());
          viewHolder.articlePreviewDescription.setText(articlePreviewItem.getDescription());
  
          return convertView;
      }
  }
  </code></pre>
  
  <p>EDIT:
  I added error.printStackTrace(); in the failure method and found this in logcat:</p>
  
  <pre><code>rss.reader W/System.err﹕ retrofit.RetrofitError: java.lang.ClassCastException: libcore.reflect.ParameterizedTypeImpl cannot be cast to java.lang.Class
  rss.reader W/System.err﹕ at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:378)
  rss.reader W/System.err﹕ at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
  rss.reader W/System.err﹕ at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
  rss.reader W/System.err﹕ at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
  rss.reader W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
  rss.reader W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
  rss.reader W/System.err﹕ at retrofit.Platform$Android$2$1.run(Platform.java:142)
  rss.reader W/System.err﹕ at java.lang.Thread.run(Thread.java:818)
  rss.reader W/System.err﹕ Caused by: retrofit.converter.ConversionException: java.lang.ClassCastException: libcore.reflect.ParameterizedTypeImpl cannot be cast to java.lang.Class
  rss.reader W/System.err﹕ at rss.reader.SimpleXMLConverter.fromBody(SimpleXMLConverter.java:39)
  rss.reader W/System.err﹕ at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:362)
  rss.reader W/System.err﹕ ... 7 more
  rss.reader W/System.err﹕ Caused by: java.lang.ClassCastException: libcore.reflect.ParameterizedTypeImpl cannot be cast to java.lang.Class
  rss.reader W/System.err﹕ at rss.reader.SimpleXMLConverter.fromBody(SimpleXMLConverter.java:37)
  rss.reader W/System.err﹕ ... 8 more
  rss.reader W/System.err﹕ retrofit.RetrofitError: java.lang.ClassCastException: libcore.reflect.ParameterizedTypeImpl cannot be cast to java.lang.Class
  rss.reader W/System.err﹕ at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:378)
  rss.reader W/System.err﹕ at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
  rss.reader W/System.err﹕ at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
  rss.reader W/System.err﹕ at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
  rss.reader W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
  rss.reader W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
  rss.reader W/System.err﹕ at retrofit.Platform$Android$2$1.run(Platform.java:142)
  rss.reader W/System.err﹕ at java.lang.Thread.run(Thread.java:818)
  rss.reader W/System.err﹕ Caused by: retrofit.converter.ConversionException: java.lang.ClassCastException: libcore.reflect.ParameterizedTypeImpl cannot be cast to java.lang.Class
  rss.reader W/System.err﹕ at rss.reader.SimpleXMLConverter.fromBody(SimpleXMLConverter.java:39)
  rss.reader W/System.err﹕ at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:362)
  rss.reader W/System.err﹕ ... 7 more
  rss.reader W/System.err﹕ Caused by: java.lang.ClassCastException: libcore.reflect.ParameterizedTypeImpl cannot be cast to java.lang.Class
  rss.reader W/System.err﹕ at rss.reader.SimpleXMLConverter.fromBody(SimpleXMLConverter.java:37)
  rss.reader W/System.err﹕ ... 8 more
  </code></pre>