【问题标题】:Edittext does not show keyboardEdittext 不显示键盘
【发布时间】:2015-03-04 10:58:43
【问题描述】:

由于某种原因,我的edittext在点击时没有显示键盘,我不知道出了什么问题,任何帮助将不胜感激

我已经使用模拟器和实际设备对此进行了测试,但都不起作用

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Notification text:"
    android:id="@+id/intro"/>

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/intro"
    android:id="@+id/txt_tekstNotif"
    android:textSize="20dp"
    android:lines="4"
    android:focusable="true"/>

<Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/txt_tekstNotif"
    android:text="@string/cre_notif"
    android:id="@+id/btn_cre_notif"/>

</LinearLayout>

【问题讨论】:

  • 尝试将其添加到您的EditTextandroid:focusableInTouchMode="true"
  • 一切似乎都正确...您可以尝试删除 EditText 的最后 2 行,并尝试将其复制粘贴到其他应用程序/项目中并进行测试。
  • 顺便说一句,请告诉我们你是如何实例化 EditText 的
  • 你有android:layout_width="wrap_content" android:layout_height="wrap_content"。当你点击 EditText 时它有任何内容吗?否则你可能根本没有点击 EditText。
  • 由于方向是垂直的,您可以将 android:layout_width="wrap_content" 更改为 android:layout_width="match_parent"

标签: android android-edittext


【解决方案1】:

您需要给 EditText 一个大小,否则它的大小为 0。 您将其设置为“wrap_content”并且您没有内容。因此,您可以为其设置一个可绘制的背景,或者在其中放置一些文本或“提示”,以便它具有实际大小。 试试把android:layout_width="50dp" android:layout_height="100" 看看它是否有效。

【讨论】:

    猜你喜欢
    • 2019-03-21
    • 2013-08-23
    • 2021-01-27
    • 2012-12-15
    • 1970-01-01
    • 2013-04-26
    • 2013-04-20
    • 1970-01-01
    相关资源
    最近更新 更多