protected StringWidget(Context context, FormEntryPrompt prompt, boolean readOnlyOverride, boolean derived) {
super(context, prompt);
mAnswer = new EditText(context);
mAnswer.setId(QuestionWidget.newUniqueId());
mReadOnly = prompt.isReadOnly() || readOnlyOverride;
mAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);
TableLayout.LayoutParams params = new TableLayout.LayoutParams();
/**
* If a 'rows' attribute is on the input tag, set the minimum number of lines
* to display in the field to that value.
*
* I.e.,
* <input ref="foo" rows="5">
* ...
* </input>
*
* will set the height of the EditText box to 5 rows high.
*/
String height = prompt.getQuestion().getAdditionalAttribute(null, ROWS);
if ( height != null && height.length() != 0 ) {
try {
int rows = Integer.valueOf(height);
mAnswer.setMinLines(rows);
mAnswer.setGravity(Gravity.TOP); // to write test starting at the top of the edit area
} catch (Exception e) {
Log.e(this.getClass().getName(), "Unable to process the rows setting for the answer field: " + e.toString());
}
}
params.setMargins(7, 5, 7, 5);
mAnswer.setLayoutParams(params);
// capitalize the first letter of the sentence
mAnswer.setKeyListener(new TextKeyListener(Capitalize.SENTENCES, false));
// needed to make long read only text scroll
mAnswer.setHorizontallyScrolling(false);
mAnswer.setSingleLine(false);
String s = prompt.getAnswerText();
if (s != null) {
mAnswer.setText(s);
}
if (mReadOnly) {
mAnswer.setBackgroundDrawable(null);
mAnswer.setFocusable(false);
mAnswer.setClickable(false);
}
addView(mAnswer);
}
StringWidget.java 文件源码
java
阅读 30
收藏 0
点赞 0
评论 0
项目:ODK-Liberia
作者:
评论列表
文章目录