android - 毕加索在滚动后显示图像
问题描述
我有一个searchview
and recyclerview
,我共享 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>
现在我向 web 发出请求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 在回收站视图中显示它,它工作得很好,但它只在我向下滚动一点时显示,我在 piccaso 中使用它onbindviewholder()
Picasso.get().load(images.get(position)).fit().networkPolicy(NetworkPolicy.NO_CACHE, NetworkPolicy.NO_STORE).centerInside().into(holder.imageView);
如何在不滚动的情况下显示图像,谢谢!
更新:添加更多功能后,它现在仅在键盘弹出时显示
解决方案
问题是我试图使用notifydatasetchanged()
内部线程,所以我将活动传递给适配器并实现了这个:
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
notifyDataSetChanged();
}
});
由于适配器项目被回收而在滚动或键盘打开时显示的图像
推荐阅读
- c# - Azure IoT 中心和设备连接
- acumatica - 销售订单中的 ShipmentList 视图
- r - 对于列表中一组变量的每个组合,计算该组合与 R 中另一个变量之间的相关性
- postgresql - 为什么不能在 PostgreSQL 中使用绑定参数定义物化视图?
- elasticsearch - 基于过滤结果的弹性搜索过滤
- java - java8减少了无用的组合器
- python - Pip 问题 - 由于 EnvironmentError 无法安装软件包
- integration - 面向软件架构师的企业应用程序集成规范
- android - 三星 S8 Android 8.0 的蓝牙 HCI 日志在哪里
- amazon-web-services - 哪个是监控(计数)API 调用的更好服务?