我有ImageView
和TextView
,显示"查看相册"。我正在使用ImageView
在Picasso
内加载图片。我想隐藏此TextView
并停用其点击,直到图片加载到ImageView
。如果未下载图片,则隐藏TextView
或显示TextView
并在单击时重定向到另一个屏幕。我尝试使用
<TextView
android:id="@+id/txtViewAlbum"
android:layout_width="fill_parent"
android:layout_height="25dp"
android:layout_gravity="center|bottom"
android:background="#435FA7"
android:clickable="false"
android:gravity="center"
android:paddingRight="4dp"
android:text="View Album"
android:textColor="#ffffff"
android:textSize="12sp"
android:visibility="gone" />
和
txtViewAlbum = (TextView) view.findViewById(R.id.txtViewAlbum);
eventImage = (ImageView) view.findViewById(R.id.imgDetail);
txtViewAlbum.setVisibility(View.GONE);
eventImage.setClickable(false);
txtViewAlbum.setClickable(false);`
首先。
使用以下方式完成图像加载:
Picasso picasso = Picasso.with(getActivity());
picasso.setDebugging(true);
picasso.setIndicatorsEnabled(false);
picasso.load(downloadPath + thumbImg).placeholder(R.drawable.no_image)
.error(R.drawable.no_image).into(eventImage, new Callback() {
@Override
public void onSuccess() {
txtViewAlbum.setVisibility(View.VISIBLE);
eventImage.setClickable(true);
txtViewAlbum.setClickable(true);
}
@Override
public void onError() {
Log.d("Error...", "picasso load error");
Picasso.with(getActivity()).load(R.drawable.no_image)
.into(eventImage);
txtViewAlbum.setVisibility(View.GONE);
eventImage.setClickable(false);
txtViewAlbum.setClickable(false);
}
});
但TextView
点击工作的时间为2-3秒,直到图像加载完毕。我想禁用它。任何帮助将不胜感激。
答案 0 :(得分:0)
尝试使用这样的东西:
mTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
runOnUiThread(new Runnable() {
@Override
public void run() {
// here disable and hide your view
}
});
// here load your image with on error loading maybe restore views to be visible again
}
});