我正在尝试使用此库Pull to refresh library
在我的sherlockListFragment中实现Pull to refresh我为listview添加了一个cutom标头。当我试图修复此标题时的问题。拉到刷新我在logcat中发现了这个错误:
05-09 09:09:43.476: E/AndroidRuntime(22559): java.lang.IllegalStateException: **Can't be used with a custom content view** 05-09 09:09:43.476: E/AndroidRuntime(22559): at android.support.v4.app.ListFragment.setListShown(ListFragment.java:282) 05-09 09:09:43.476: E/AndroidRuntime(22559): at android.support.v4.app.ListFragment.setListShown(ListFragment.java:258) 05-09 09:09:43.476: E/AndroidRuntime(22559): at com.openbee.v3.fragments.NotifsFileFragment.onRefreshStarted(NotifsFileFragment.java:355)
如何通过自定义内容视图解决此问题以及刷新刷新。有我的代码:
NotifsFileFragment:
public class NotifsFileFragment extends SherlockListFragment implements OnRefreshListener {
public static ActionMode mActionMode;
private static Notifs_file_adapter adapter;
public static ArrayList<DocumentRow> itemData;
private static final String TAG_COLOR = "color";
private RelativeLayout mRelativeLayout;
private ImageView mImageView;
private Drawable icon_header_Drawable;
int selectednumber;
private PullToRefreshLayout mPullToRefreshLayout;
View listvView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
super.onCreateView(inflater, container,
savedInstanceState);
View view = inflater.inflate(R.layout.header_queue, container, false);
mImageView = (ImageView) view.findViewById(R.id.icon_header_list);
listvView = (ListView) view.findViewById(R.id.list);
icon_header_Drawable = getResources().getDrawable(R.drawable.ic_header_notif_file);
mImageView.setImageDrawable(icon_header_Drawable);
TextView mTextView = (TextView) view.findViewById(R.id.text_header);
mTextView.setText("Notifications des documents");
// setListShownNoAnimation(true);
return view;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view,savedInstanceState);
ViewGroup viewGroup = (ViewGroup) view;
// As we're using a ListFragment we create a PullToRefreshLayout manually
mPullToRefreshLayout = new PullToRefreshLayout(viewGroup.getContext());
// We can now setup the PullToRefreshLayout
ActionBarPullToRefresh.from(getActivity())
// We need to insert the PullToRefreshLayout into the Fragment's ViewGroup
.insertLayoutInto(viewGroup)
// Here we mark just the ListView and it's Empty View as pullable
.theseChildrenArePullable(android.R.id.list, android.R.id.empty)
.listener(this)
.setup(mPullToRefreshLayout);
}