Ayan
Ayan

Reputation: 27

How to Initial keyboard start with Uppercase letter and when press dot again start with Uppercase letter in soft keyboard

I have Tried these InputType but my issue not solve. My XML you can see. Please any suggestion.I extended softkeyboard class public class SoftKeyboard extends InputMethodService implements KeyboardView.OnKeyboardActionListener, SharedPreferences.OnSharedPreferenceChangeListener { – Thanks in advance.

<?xml version="1.0" encoding="utf-8"?>
<LatinKeyboardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/urduSimple"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true"
android:alpha="1"
android:imeOptions="actionSearch"
android:inputType="textCapSentences"
android:keyBackground="@drawable/transparent_key_shape"
android:keyPreviewLayout="@layout/key_preview"
android:keyPreviewOffset="-4dp"
android:keyTextColor="@color/White"
android:paddingTop="4dp"
android:keyTextSize="28dp"
android:shadowRadius="0.0"
 android:popupLayout="@layout/keyboard_popup_layout">
 </LatinKeyboardView>
 Java:
            case InputType.TYPE_CLASS_TEXT:
            EditText editor = new EditText(this);
            editor.setInputType(InputType.TYPE_CLASS_TEXT | 
            InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);

Upvotes: 1

Views: 284

Answers (1)

SpiritCrusher
SpiritCrusher

Reputation: 21063

textCapSentences will work if user do not manually change the Softkeyboard to lower case. A normaly sentence ends with dot and a space after it.So it will perfectly work for this formate.

<EditText
    android:id="@+id/et"
    android:layout_width="match_parent"
    android:inputType="textCapSentences"
    android:layout_height="wrap_content" />

If user manually change the Keyboard then you should use a TextWatcher to formate the text again in sentence case.

Upvotes: 2

Related Questions