简体   繁体   中英

How to validate a textview in android?

I have a text-view with one background image (eg a signature image). When the user clicks on the text-view it retrieves a sign from the database and sets it as a background for the text-view. I want to validate the text-view (ie ensure that the text-view background is a signature or database sign).

How can I do that?

You can use getBackground() to get the drawable that is currently set as the background.'

However, a better method would be to use setTag("signature") when setting the signature image, and setTag("database") when setting the database image, and then comparing it later using ((String)getTag()).equals(<whatever you want to check>)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM