public class XXXFragment extends BaseFragment implements XXXClick{
method(){
ABC.method(this);
}
}
public class XXXActivity extends BaseActivity implements XXXClick{
method(){
ABC.method(this);
}
}
XXXFragment 是Fragment的子类;XXXActivity 是Activity的子类
public class ABC{
method(Object obj){
if(obj instanceof Activity){
...
}else{
if(obj instanceof Fragment){
...
}
}
}
}
I know how to solve the problems I encountered. . . Thank you upstairs. When passing this, I can directly convert it into the required object to solve my needs. .
The instanceof operator returns true if object is an instance of class. If object is not an instance of the specified class, or object is null, returns false