微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

毕加索滚动后显示图像

如何解决毕加索滚动后显示图像

我有一个searchviewrecyclerview,我共享xml代码

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
 <SearchView
            android:id="@+id/searchinput"
            android:layout_width="match_parent"
            android:background="#FFFFFF"
            android:searchIcon="@null"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true" />
    
        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/searchinput"
            android:layout_alignParentStart="true" />
    
    </RelativeLayout>

现在我向网络onQueryTextSubmit(String query)发出请求,我在适配器类中调用一个函数,在其中执行以下操作

 public void filterData(String query){
        query=query.toLowerCase();
        
        if(query.isEmpty()){
            images.clear();
            images.addAll(orignallist);
            notifyDataSetChanged();
            
        }
        else {
         // This is main function
            getimages(query);
        }
    }

在这里通过jsoup在与网络不同的线程中获取图像url,并通过piccaso在回收器视图中显示它,效果很好,但仅在向下滚动时显示,我在{{1 }}

onbindviewholder()

如何在不滚动的情况下显示图像,谢谢!

搜索按钮单击

enter image description here

时,向下滚动

enter image description here

更新:添加更多功能后,现在仅在键盘弹出时显示

解决方法

问题是我试图在线程内部使用notifydatasetchanged(),所以我将活动传递给适配器并实现了这一点:

activity.runOnUiThread(new Runnable() {
@Override
 public void run() {
 notifyDataSetChanged();
 }
 });

由于适配器项被回收而在滚动或键盘打开时显示的图像

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。