如何检查imageview中的源代码?
问题描述:
如果存在与列表关联的图形或其“不可见”,则需要检查按钮单击。我通过查看绘图的来源是@ drawable /不可见还是别的东西来做检查。如果别的东西然后将其更改为不可见,如果不可见然后将其更改为一种颜色等等如何检查imageview中的源代码?
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View listview, int position,
long arg3) {
ImageView pincolor=(ImageView) listview.findViewById(R.id.ivimtrackingpin);
// here is where I want to check what the "source" is
if(pincolor.getResources().equals(R.drawable.invisible)
//do stuff
else
pincolor.setImageresource(R.drawable.invisible)
}
});
我不想只是做setvisibility =看不见的,因为有不同的颜色,每个列表可并且开关功能将进入if部分。我使用什么方法来确定图像查看源?
感谢
答
也许你可以使用的ImageView getDrawable()方法。
/**
* Return the view's drawable, or null if no drawable has been assigned.
*/
public Drawable getDrawable()
这样的:
ImageView pincolor=(ImageView) listview.findViewById(R.id.ivimtrackingpin);
Drawable drawable = pincolor.getDrawable();
if(drawable != null) {
//do stuff with the drawable
} else {
pincolor.setImageresource(R.drawable.invisible)
}
答
这会告诉你,如果认为是无形的:
pincolor.getVisibility()==View.INVISIBLE