如何检查图像视图中的源是什么?
我需要检查按钮单击是否有与列表关联的绘图或其“不可见”。我正在通过查看绘图的来源是否为 @drawable/invisible 或其他内容来进行检查。如果是其他东西,则将其更改为不可见,如果不可见,则将其更改为颜色等...
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 =invisible 因为每个列表可以有不同的颜色,并且切换功能将进入内部如果部分。我使用什么方法来确定 imageviews 来源?
谢谢
I need to check on a button click if there is a drawing associated with the list or if its "invisible". I am doing the check by seeing if the source of the drawing is @drawable/invisible or something else. If its something else then change it to invisible, if invisible then change it to a color etc...
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)
}
});
I don't want to just do setvisibility =invisible because there are different colors that each list can be and the switch function will go inside the if part. What method do I use to determine the imageviews source?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您可以利用 ImageView 的 getDrawable() 方法。
像这样:
Maybe you can make use of the ImageView's getDrawable() Method.
like this:
这将告诉您视图是否不可见:
This will tell you if the view is invisible: