Java 类android.text.method.TextKeyListener.Capitalize 实例源码

项目:sagesmobile-mCollect    文件:StringWidget.java   
protected StringWidget(Context context, FormEntryPrompt prompt, boolean derived) {
    super(context, prompt);
    mAnswer = new EditText(context);
    mAnswer.setId(QuestionWidget.newUniqueId());
    mReadOnly = prompt.isReadOnly();

    mAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);

    TableLayout.LayoutParams params = new TableLayout.LayoutParams();
    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);
}
项目:ODK-Liberia    文件:StringWidget.java   
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);
}
项目:commcare-android    文件:StringWidget.java   
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);
    }
}
项目:BluetoothHidEmu    文件:KeyboardKeyListener.java   
public KeyboardKeyListener(SocketManager socketManager) {
    super();

    mTextKeyListener = new TextKeyListener(Capitalize.NONE, false);
    mSocketManager = socketManager;

}