2013-02-17 120 views

回答

0

就設定爲您佈局的TextView的android:capitalize XML屬性。檢查可能的值屬性here

+0

我下發展鍵盤,textView可能來自不同的應用程序。我需要在鍵盤上設置這個邏輯來在這些文本視圖中大寫字母。 – 2013-02-17 06:58:52

1

必須是有點晚了回答,但別人可能需要這個

要手動大寫鍵盤,你要打電話給你KeyboardViewsetShifted (boolean shifted)法所需移模式

下面是一個例子:。

private KeyboardView mInputView; 
... 
mInputView.setShifted(true); 

但是,如果讓SoftKeyboard通過檢查文本編輯器的屬性來決定其大小寫模式會更好。例如,電子郵件通常使用小寫字母輸入。 如果你看看這個樣本here,它有一個名爲updateShiftKeyState(EditorInfo attr)方法,該方法使用基於在該文本將在鍵入文本編輯器的初始屬性,自動設置資本化模式:

/** 
* Helper to update the shift state of our keyboard based on the initial 
* editor state. 
*/ 
private void updateShiftKeyState(EditorInfo attr) { 
    if (attr != null 
      && mInputView != null && mQwertyKeyboard == mInputView.getKeyboard()) { 
     int caps = 0; 
     EditorInfo ei = getCurrentInputEditorInfo(); 
     if (ei != null && ei.inputType != InputType.TYPE_NULL) { 
      caps = getCurrentInputConnection().getCursorCapsMode(attr.inputType); 
     } 
     mInputView.setShifted(mCapsLock || caps != 0); 
    } 
}