Android 错误无法比较的类型:Object 和 int
Android error incomparable types: Object and int
我正在导入源代码,但在两个代码位置出现了这个错误:
Error:(86, 60) error: incomparable types: Object and int
if (selectedPhotos.containsKey(photoEntry.imageId)) {
selectedPhotos.remove(photoEntry.imageId);
v.setChecked(false, true);
photoEntry.imagePath = null;
photoEntry.thumbPath = null;
v.setPhotoEntry(photoEntry, v.getTag() == MediaController.allPhotosAlbumEntry.photos.size() - 1);
// ^-here-^
} else {
selectedPhotos.put(photoEntry.imageId, photoEntry);
v.setChecked(true, true);
还有这个:
if (passwordFrameLayout.getTag() != 0) {
// ^Here
t = (Integer) passwordFrameLayout.getTag();
}
我应该对这些进行哪些更改?
我在 Stack 中搜索过,但无法修复它们。我是这方面的新手,请帮忙。
我用的是AndroidStudio Last Version!
我正在开发主要 Telegram source,没有任何变化。
并获取标签功能:
@ViewDebug.ExportedProperty
public Object getTag() {
return mTag;
}
在android-23/android/view/View.java
if (passwordFrameLayout.getTag() instanceOf Integer && (Integer)passwordFrameLayout.getTag() != 0) {
//
t = (Integer) passwordFrameLayout.getTag();
}
应该可以解决问题。 getTag()
returns一个对象,你必须
- 首先确保它是一个整数
- 将其转换为整数
将它与另一个整数进行比较
我正在导入源代码,但在两个代码位置出现了这个错误:
Error:(86, 60) error: incomparable types: Object and int
if (selectedPhotos.containsKey(photoEntry.imageId)) {
selectedPhotos.remove(photoEntry.imageId);
v.setChecked(false, true);
photoEntry.imagePath = null;
photoEntry.thumbPath = null;
v.setPhotoEntry(photoEntry, v.getTag() == MediaController.allPhotosAlbumEntry.photos.size() - 1);
// ^-here-^
} else {
selectedPhotos.put(photoEntry.imageId, photoEntry);
v.setChecked(true, true);
还有这个:
if (passwordFrameLayout.getTag() != 0) {
// ^Here
t = (Integer) passwordFrameLayout.getTag();
}
我应该对这些进行哪些更改?
我在 Stack 中搜索过,但无法修复它们。我是这方面的新手,请帮忙。
我用的是AndroidStudio Last Version!
我正在开发主要 Telegram source,没有任何变化。
并获取标签功能:
@ViewDebug.ExportedProperty
public Object getTag() {
return mTag;
}
在android-23/android/view/View.java
if (passwordFrameLayout.getTag() instanceOf Integer && (Integer)passwordFrameLayout.getTag() != 0) {
//
t = (Integer) passwordFrameLayout.getTag();
}
应该可以解决问题。 getTag()
returns一个对象,你必须
- 首先确保它是一个整数
- 将其转换为整数
将它与另一个整数进行比较