Android如何检查对象的类型

The instanceof operator compares an object to a specified type. You can use it to test if an object is an instance of a class, an instance of a subclass, or an instance of a class that implements a particular interface.

示例代码:

void checkforTextView(View v)
{     if(v instanceof TextView)    
 {         // This is a TextView control     } 
else 
{         // This is not a TextView control     } }