Android 毕加索在滚动后显示图像
我有一个Android 毕加索在滚动后显示图像,android,picasso,Android,Picasso,我有一个搜索视图和回收视图,我共享xml代码 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <SearchView androi
搜索视图
和回收视图
,我共享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>
我在这里通过jsoup从web上获取一个单独的线程中的图像url,并通过piccaso在recycler视图中显示它,它工作得很好,但只在我向下滚动一点时显示,我在onbindviewholder()中将它与piccaso一起使用。
如何在不滚动的情况下显示图像,谢谢
单击搜索按钮时,向下滚动一点
更新:添加更多功能后,现在仅当键盘弹出时才会显示该功能问题是我试图在线程内使用
notifydatasetchanged()
,因此我将活动传递给适配器并实现了以下功能:
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
notifyDataSetChanged();
}
});
由于适配器项目被回收,在滚动或键盘打开时显示的图像可以添加整个适配器代码吗?请尝试在两种
if-else
条件下添加notifyDataSetChanged
,或者在if-else
条件下添加(可能是错误在于您没有在else条件下使用NOTIFYDATASETCHANGE
)@VivekThummar我在线程中使用了NOTIFYDATASETCHANGE(),我认为这就是问题所在,好的,我会解决它,但为什么当键盘打开时会自动调用NOTIFYDATASETCHANGE()?
Picasso.get().load(images.get(position)).fit().networkPolicy(NetworkPolicy.NO_CACHE, NetworkPolicy.NO_STORE).centerInside().into(holder.imageView);
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
notifyDataSetChanged();
}
});