public StringWidget(Context context, FormEntryPrompt prompt, boolean secret, boolean inCompactGroup) {
super(context, prompt, inCompactGroup);
mAnswer = (EditText)LayoutInflater.from(getContext()).inflate(getAnswerLayout(), this, false);
mAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontSize);
mAnswer.setOnClickListener(this);
mAnswer.addTextChangedListener(this);
//Let's see if we can figure out a constraint for this string
try {
addAnswerFilter(new InputFilter.LengthFilter(guessMaxStringLength(prompt)));
} catch (UnpivotableExpressionException e) {
//expected if there isn't a constraint that does this
}
this.secret = secret;
if (!secret) {
// capitalize the first letter of the sentence
mAnswer.setKeyListener(new TextKeyListener(Capitalize.SENTENCES, false));
}
setTextInputType(mAnswer);
if (!secret) {
mAnswer.setSingleLine(false);
}
if (prompt != null) {
mReadOnly = prompt.isReadOnly();
IAnswerData value = prompt.getAnswerValue();
if (value != null) {
mAnswer.setText(value.getDisplayText());
}
if (mReadOnly) {
if (value == null) {
mAnswer.setText("---");
}
mAnswer.setBackgroundDrawable(null);
mAnswer.setFocusable(false);
mAnswer.setClickable(false);
}
}
if (isInCompactMode()) {
addToCompactLayout(mAnswer);
} else {
addView(mAnswer);
}
}
StringWidget.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:commcare-android
作者:
评论列表
文章目录