下面列出了android.widget.GridView#AUTO_FIT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public int parseColumnCount(List<PXStylesheetLexeme> lexemes) {
setupWithLexemes(lexemes);
int result = GridView.AUTO_FIT;
try {
result = getColumnCount();
} catch (Exception e) {
addError(e.getMessage());
}
return result;
}
private int getColumnCount() {
int result = GridView.AUTO_FIT;
PXStylesheetTokenType currentType = currentLexeme.getType();
Object value = currentLexeme.getValue();
// If currentType is a number, that's the number of columns. If it's an
// IDENTIFIER, then the only valid value is "auto". If it's anything
// else, it's an invalid value and we'll anyway use the default of
// "auto".
switch (currentType) {
case NUMBER:
if (value instanceof Number) {
result = ((Number) value).intValue();
} else {
result = Integer.parseInt((String) value);
}
break;
case IDENTIFIER:
// Check is here to just show the warning if applicable. Default
// of "auto" is only valid value.
if (!("auto".equals(value))) {
exceptionWithMessage("'" + value + "' unrecognized as value for column count.");
}
break;
default:
exceptionWithMessage("'" + value + "' unrecognized as value for column count.");
}
advance();
return result;
}