How to change label of any key on Android default keyboard.
I want to do something like this,
you can acheive this by using Use KeyboardView:
KeyboardView kbd = new KeyboardView(context);
kbd.setKeyboard(new Keyboard(this, R.xml.customlayout));
kbd.setOnKeyboardActionListener(new OnKeyboardActionListener() {
....
}
now you have kd which is a normal view.
The nice thing about this is that R.xml.custom refers to /res/xml/custom.xml, which defines in xml the layout of the keyboard. For more information on this file, look here: Keyboard, Keyboard.Row, Keyboard.Key.
You can use your own keyboard to change the text and style of keyboard.
Custom Keyboard
you should have a look at ImeActionLabel or ImeActionId
<EditText android:id="#+id/some_edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:imeOptions="actionSend">
</EditText>
Read this answer for more details
Related
How can I disable spelling corrections in an EditText's soft-keyboard programmatically in Android? The user can disable it from settings, but I need to disable it in my application.
Is there any way to do this?
Set this in your layout's xml for your EditText:
android:inputType="textNoSuggestions"
Or call setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) in your Activity'
If you need to support API 4 and below, use android:inputType="textFilter"
If setting:
android:inputType="textNoSuggestions"
still doesn't work (and your text field is small), a quick work-around is to use:
android:inputType="textVisiblePassword"
I have an EditText in Android configured for the number keyboard, and I would like the keyboard's button to say "next", while mine is saying "done".
How can I change that?
I already tried:
<com.innovattic.font.FontEditText
style="#style/CadastroTextBoxStyle"
android:hint="CEP"
android:id="#+id/etCEP"
android:inputType="number"
android:singleLine="true"
android.imeOptions="actionNext" />
And also this:
etCEP.setImeActionLabel("Next", KeyEvent.KEYCODE_ENTER);
But it still says done.
What else can I do?
Thanks
As can be seen in Specifying the Input Method Type, you do not need to call TextView.setImeActionLabel(CharSequence, int) and you have to instead just provide a android:imeOptions value such as actionSend or actionNext in XML attributes to change the label accordingly.
This is not working for you because you have mistyped : as . in your attributes. Switching those out should fix your issue in no time.
I have such a question - if you use DateTime widget, its keyboard on editing date value looks like this:
But when you try to set numeric or date input on custom EditText the resulting keyboard usually looks like this:
Is there a way to get just numeric Keyboard like the first one on EditText? Thanks for help.
Add android:inputType="number" to your edit text
Add android:inputType="phone" to your edit text
I'm building a custom keyboard by modifying the android softkeyboard sample from the SDK. I want to change the images of the buttons and the backgrounds but I can't figure out where those values are stored. Where are they stored or how can i change the image or simply color?
in onClick method you need to change the Button's image, this way..
public void onClick(View v) {
if(v==buttonName){
buttonName.setBackgroundResource(R.drawable.imageName);
}
}
The keyboard background color can be changed in input.xml using android:background
You need to edit the file res/xml/qwerty.xml.
You can check the documentation for Keyboard and the Keys. The last one defines what is shown on the keys (does not look like you can change the background though).
You need to edit the file
res/layout/input.xml
A sample input.xml could look like this.
<com.example.keyboard.LatinKeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/keyboard"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/keyboardbackground"
android:keyBackground="#drawable/samplekeybackground"
android:keyPreviewLayout="#layout/input_key_preview"
android:keyTextcolor="#android:color/black"/>
there are few more attributes that can be found in the KeyboardView documentation.
If you open an app like gmail, and you compose a new email in the To and Subject lines, it says To and Subject in the respective EditText's. How do you add a title like that to an EditText? Are those custom views? Or is it possible to do that with the default widget?
Thanks.
It is called a hint.
Set your hint programatically or use it as xml attribute.
I think the attribute hint is what you are looking for.
Here is some sample code:
<EditText android:hint="Write Caption" />