0

我想使用/创建一个与 (HTC Desire) 软键盘上的按钮类似的按钮。这样当您长按时,它会显示一个选项列表,通过向左或向右滑动手指,您可以选择要选择的选项。

示例:当我按住键盘上的“12#”按钮时,它会显示列表:[:/@_-!? '],通过向左或向右滑动,它会突出显示这些字符之一,并在我松开手指时选择选定的字符。如果我只是正常单击,它会选择默认字符。

Android SDK中是否有这样的小部件,或者任何人都可以提示如何实现这样的组件。

看截图:输入文字,然后长按“12#”按钮。“!” 当前被选中。

替代文字

4

1 回答 1

1
  1. 创建一个自定义活动android:theme="@android:style/Theme.Dialog"(这将使它具有透明的浮动对话框外观)。
  2. 添加到LinearLayoutandroid:orientation="horizontal"
  3. 添加一些带有图标的按钮到LinearLayout. 这将创建一个透明的 Button,其下方有一个 Icon 和一些文本:

    <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. 使用Button.onKeyLongPress(..)显示此活动。

于 2010-10-31T20:44:13.507 回答