【问题标题】:How to add a little 'information' button to my Android application如何在我的 Android 应用程序中添加一点“信息”按钮
【发布时间】:2014-09-10 07:32:42
【问题描述】:

我不太确定这是否还没有得到回答,因为我觉得这个问题很难简洁地提出,无论如何我发现它很困难。

我想要的是,例如,我有一个 EditText,提示可能对某些人有意义(小提示),但我觉得对其他人来说,他们可能需要更多解释/或示例。

所以我想要一个小圆形“i”按钮,代表 EditText 旁边的信息。我希望这个按钮做的是,一旦被触摸,就会弹出一个 toast 窗口,显示我想要的帮助信息。

我认为您可以从用户体验中想象出我正在使用的功能!但我似乎无法找到一种很好的方法来做到这一点,就像我想象的那样。

现在,如果在您知道的某个地方已经有一个明确的例子,那么链接会很棒,如果没有,一些带有一些解释的代码会很棒。我是 java 和 android 开发的新手,但我正在慢慢但肯定地到达那里。

非常感谢您,再次感谢您的帮助或提示!

【问题讨论】:

  • 真的,你需要编辑删除我的感激之情?和我的问候。似乎有点傻,只是想得到一些帮助。

标签: android user-interface android-toast information-hiding


【解决方案1】:

获取您想要的 i 的图像。将图像视图添加到您的布局中,并在其中使用该图像。为该 ImageView 设置一个 onClickListener,并让该侦听器启动您要显示的 toast。

【讨论】:

    【解决方案2】:

    如果你只想放置一个drawable,你可以使用下面的代码。

    android:drawableRight="@drawable/my_icon" />

    而如果你是在edittext中寻找点击图片,有几种方法:

    1) 您可以使用 see this 自定义布局。

    2) 通过在相对布局中使用编辑文本和按钮来检查以下代码

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >
    
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="Enter search key" />
    
    <ImageButton
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:src="@drawable/search"
        android:layout_centerVertical="true"
        android:layout_margin="5dp"
        android:text="Button"/>
    
       </RelativeLayout>
    

    3) 通过自定义相对布局检查 this 链接

    【讨论】:

    • 非常感谢您的帮助:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-31
    相关资源
    最近更新 更多