在 View.java 中,
setId - “设置此视图的标识符。标识符在此视图的层次结构中不必是唯一的。标识符应该是一个正数。”
&
findViewById - "查找具有给定 id 的子视图。如果此视图具有给定 id,
为什么我不能使用负数作为视图的 id?我注释掉了
public final View findViewById(int id) {
// The original android check at here
// if (id < 0) {
// is commented out to test if system could run when Ids are negative numbers
if (id == NO_ID) {
return null;
}
return findViewTraversal(id);
}
该系统似乎工作正常。