【问题标题】:android 4.0 and higher : Copy/paste/cut panel disappears onLongClick Listener on the EditTextandroid 4.0 及更高版本:复制/粘贴/剪切面板在 EditText 上消失 onLongClick 侦听器
【发布时间】:2014-06-27 14:29:23
【问题描述】:

我在选项卡中使用 PreferenceActivity 并添加带有 editText 的页脚:

 <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:foo="http://schemas.android.com/apk/res/com.assignmentexpert"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:orientation="vertical">
  <TableLayout 
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:shrinkColumns="2"
    android:stretchColumns="0"
    >
    <TableRow
          android:id="@+id/tableRow1"
          style="@style/text_row" 
          android:layout_weight="1"
          >
  <com.customitems.CustomEditText
        android:id="@+id/taskText"
        style="@style/custom_edittext"
        android:gravity="top|left"
        android:maxLength="8192"
        android:layout_marginLeft= "25dp"
        android:layout_height="110dp"
        android:imeOptions="actionDone"
        android:layout_weight="1"
        android:layout_width="fill_parent"
        android:scrollbars = "vertical"
        android:layout_marginRight="10dp"
        foo:customFont="Roboto-Regular.ttf"
        android:hint="@string/hint_assignment_task"/>


  </TableRow>
         <TableRow android:layout_height="1px" android:background="#323232">
    <TextView android:layout_span="1" android:layout_height="1px" 
             android:layout_width="fill_parent" android:text="">
     </TextView>
        </TableRow>
  <TableRow
          android:id="@+id/tableRow1"
          style="@style/text_row" 
          android:layout_weight="1"
          >
  <com.customitems.CustomEditText
        android:id="@+id/taskSpecReq"
        style="@style/custom_edittext"
        android:gravity="top|left"
        android:maxLength="8192"
        android:layout_marginLeft= "25dp"
        android:layout_height="110dp"
        android:imeOptions="actionDone"
        android:layout_weight="1"
        android:layout_width="fill_parent"
        android:scrollbars = "vertical"
        android:layout_marginRight="10dp"
        foo:customFont="Roboto-Regular.ttf"
        android:hint="@string/hint_assignment_specific_requirements"/>

     </TableRow>

  </TableLayout>

 </LinearLayout>

所以,当我在taskTest EditText 上使用 LongClick 时,复制/粘贴/剪切会出现并且可以正常工作。但是当我长按taskSpecReq 我的taskSpecReq 复制/粘贴/剪切面板和选项卡从屏幕上消失。 taskSpecReq 位于屏幕底部。

长按第一个 EditText :

长按第二个 EditText:

【问题讨论】:

    标签: java android android-edittext


    【解决方案1】:

    当我在其中使用 TabHost 和嵌套的 Activity 时,我通过使用

    解决了它
      android:windowSoftInputMode="stateUnspecified" 
    

    对于 TabActivity 和嵌套的 Activity :

      android:windowSoftInputMode = "adjustResize"
    

    它解决了我的问题。

    【讨论】:

      【解决方案2】:

      看起来系统可能正在滚动您的视图以确保CustomEditText 的光标在软键盘上方可见,因此将顶部滚动到屏幕之外。查看AndroidManifest.xml 中您的活动的android:windowSoftInputMode 属性,描述为here

      (确认是否是这种情况的一种简单方法是切换您的两个 CustomEditText 小部件。如果问题总是出现在底部的小部件上,那么可能就是它。)

      【讨论】:

      • @RikkiTikkiTavi 不使用adjustPan 会导致问题吗?
      • 我不知道。 adjustPan 可以很好地使 EditText 正确聚焦。因为没有它,软键盘的行为会很奇怪。
      猜你喜欢
      • 2013-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多