views:

67

answers:

1

I want to use/create a button that works like the one on the (HTC Desire) Soft Keyboard. So that when you make a long click, it will show a list of options, and by sliding your finger to the left or right, you select which option you want to choose.

Example: When I hold down the "12#" button on the keyboard, it presents the list: [: / @ _ - ! ? '], and by sliding left or right it highlights one of these characters and chooses the selected one when I release my finger. If I just click normally, it selects the default character.

Is there such a widget in the Android SDK, or can anyone give a hint on how to implement such a component.

See screenshot: Entering text, and just long pressed the "12#" button. "!" is currently selected.

alt text

A: 
  1. Create a custom Activity with android:theme="@android:style/Theme.Dialog" (this will give it a transparent, floating dialog look).
  2. Add to it a LinearLayout with android:orientation="horizontal"
  3. Add some button with icons to LinearLayout. This creates a transparent Button with an Icon and some text beneath it:

    <Button android:id="@+id/optionsButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dip"
            android:text="@string/button_options_text"
            android:textColor="@color/button_text_grey"
            android:drawableTop="@drawable/button_options"
            android:drawablePadding="-5dip"
            android:background="@null"
    
  4. Use Button.onKeyLongPress(..) to show this Activity.

Peter Knego