I have an UI with some TextViews and I want to test if a textView has a certain drawable resource as background. I'm using the following code, but the tag
is always null.
Object tag = textView.getTag();
int backgroundId = R.drawable.bg_image_2;
if( tag != null && ((Integer)tag).intValue() == backgroundId) {
//...do something...
}else{
//...do something...
}
Which method returns the R.drawable
background id number of an object? What am I doing wrong?
如果标记为null,那是因为您没有使用setTag
影响对象
Tag is a feature for developer to save some object with Widget, you have use setTag() to save an arbitary object with UI widget. If you didn't setTag(), then getTag() would return NULL.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.