3

I am trying to include Chris Banes Pull to refresh implementation inside a Fragment and I am getting the following error at creating the PullToRefreshListView:

java.lang.NoSuchFieldError: com.handmark.pulltorefresh.library.R$id.pull_to_refresh_text

The point of PullToRefreshListView creation is at onCreateView in a class inheriting ListFragment:

public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {

    ViewGroup viewGroup = (ViewGroup) super.onCreateView(inflater, container, savedInstanceState);

    View lvOld = viewGroup.findViewById(android.R.id.list);

    listView = new PullToRefreshListView(getActivity());
    listView.setId(android.R.id.list);
    listView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    listView.setDrawSelectorOnTop(false);
    adapter = new LazyAdapter(getActivity());
    listView.setAdapter(adapter);

    FrameLayout parent = (FrameLayout) lvOld.getParent();

    parent.removeView(lvOld);
    lvOld.setVisibility(View.GONE);

    parent.addView(listView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    return viewGroup;

}

The layout is like:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="#FF0000">

    <ListView
        android:id="@+id/android:list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
    />

</LinearLayout>

What am I missing?

Michael Celey
  • 12,645
  • 6
  • 57
  • 62
user1524261
  • 31
  • 1
  • 4

1 Answers1

1

I've got the same error after replacing of "pull to refresh" widget http://markupartist.com from Johan Nilsson. It was necessary to delete header.xml from layout directory (containing references to the text mentioned in your error message). Texts are already part of the Chris Banes's library.

Michal Harakal
  • 1,025
  • 15
  • 21
  • Thank you so much! It appears to be a problem that I had both libraries referenced and the layout name was the same. I delete the reference for Johan Nilsson´s library and now is working :) – user1524261 Jul 21 '12 at 17:55