Fouad
Fouad

Reputation: 855

Android keyboard popupCharacters issues

I am developing a custom keyboard for android. I am trying to create a button when pressed smiley faces should popup. It has come to my understanding that android:popupCharacters is responsible for displaying a popup on the keyboard as well as android:popupKeyboard. My problem is that for example if i put android:popupCharacters=":) :(" i get a popup with each character on a button by itself. How is it done?

Thanks in advance

Upvotes: 6

Views: 3194

Answers (4)

pachuau
pachuau

Reputation: 81

Create a separate xml layout for popups in xml directory as the following

<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
    android:keyWidth="15%p"
    android:horizontalGap="0px"
    android:verticalGap="0px"
    android:keyHeight="@dimen/key_height"
    >

<Row android:rowEdgeFlags="top">
        <Key android:keyLabel=":-)" android:keyOutputText=":-) "
        <Key android:keyLabel=":-)" android:keyOutputText=":-( "
    </Row>
</Keyboard>

Add as many row and/or key attributes as you like for additional smileys then use this in your keyboard xml

    <Key android:keyOutputText=":-)" android:keylabel=":-)" android:popupKeyboard="@xml/popup"/>

This will create a key ":-)" which will output the character :-) if you press it once, and use the popup xml layout when you long press it.

Upvotes: 2

Gagan
Gagan

Reputation: 1497

If I have understood your query correctly and you want to implement something similar to Watsapp-smiley-button, then you can make use of PopupWindow in onClick of your button and add different smileys to it.

Upvotes: 1

baldguy
baldguy

Reputation: 2082

If you are making your own keyboard then check this following source code available which will help you a lot.

Scandinavian-keyboard

Hackers Keyboard

Android Emoji Keyboard

Also you want to change theme of your keyboard then check following link.It will give you clear idea of how to make preview layout and all. And specially if you want to check about smiley then Android Emoji Keyboard will be very useful. It uses smiley symbols in keyboard and also in preview too.

Hope this will help you.

Upvotes: 1

lajos.cseppento
lajos.cseppento

Reputation: 897

Read the doc carefully: http://developer.android.com/reference/android/inputmethodservice/Keyboard.Key.html#attr_android:popupCharacters

android:popupCharacters

The characters to display in the popup keyboard.

[...]

android:popupKeyboard

The XML keyboard layout of any popup keyboard.

So popupcharacters means a simpler way to create popupkeyboard. But Unicode comes and saves you from creating XML and using images: http://unicodeemoticons.com/ Try them! (Once I tried a long time ago, well displayed on 2.2 emulator, ZTE Blade and T-Mobile Pulse / Huwaei U8220).

If you don't want this workaround, the other soulution is if you go into the android SDK source, and try to reimplement the whole popup keyboard (or over-implement, if you can) to make it available for you. But anyway, if I was the user, I would be more happy for the unicode or the images, but this is only my opinion.

Upvotes: 5

Related Questions