gpt4 book ai didi

android - Chris Banes 拉动刷新 Fragment 中的 ListView/GridView

转载 作者:太空狗 更新时间:2023-10-29 14:26:55 25 4
gpt4 key购买 nike

我试图在 Fragment 中包含 Chris Banes Pull 以刷新实现,但在创建 PullToRefreshListView 时出现以下错误:

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

PullToRefreshListView 的创建点在继承 ListFragment 的类中的 onCreateView:

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;

}

布局是这样的:

<?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>

我错过了什么?

最佳答案

替换“拉动刷新”小部件后我遇到了同样的错误 http://markupartist.com from Johan Nilsson .有必要从布局目录中删除 header.xml(包含对错误消息中提到的文本的引用)。文本已经是 Chris Banes 图书馆的一部分。

关于android - Chris Banes 拉动刷新 Fragment 中的 ListView/GridView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11478047/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com