以下是我正在使用的代码。
@Override
public void onBindViewHolder(final ViewHolderBoxOffice holder, int position)
{
holder.topContainer.setVisibility(View.INVISIBLE);
holder.bottomContainer.setVisibility(View.INVISIBLE);
String poster = "some image url";
holder.mThumbnail.setImageUrl(poster, volleySingleton.getImageLoader());
/* Listener for listening to image loading*/
holder.mThumbnail.addOnLayoutChangeListener(new OnLayoutChangeListener()
{
@Override
public void onLayoutChange(View view, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7,
int arg8)
{
if(holder.mThumbnail.getDrawable()!=null)
{
holder.topContainer.setVisibility(View.VISIBLE);
holder.bottomContainer.setVisibility(View.VISIBLE);
}
else
{
holder.topContainer.setVisibility(View.INVISIBLE);
holder.bottomContainer.setVisibility(View.INVISIBLE);
}
}
});
}