我有兩個類:類繼承
class ItemInfo {
public View createItemView() {
View v;
// ...
v.setTag(this);
return v;
}
}
class FolderInfo extends ItemInfo {
@Override
public View createItemView() {
View v;
// ...
v.setTag(this);
return v;
}
}
然後我使用它:
FolderInfo folderInfo;
// Create it here
ItemInfo itemInfo = folderInfo;
View v = itemInfo.createItemView();
Object objectTag = v.getTag();
然後,我通過instanceof檢查objectTag的類型,它的ItemInfo!爲什麼?
你檢查什麼類型的變量? – berry120 2012-07-12 11:20:54