- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
伙计们,这就是我现在的问题。
我有下一个 TextView 和 EditText
<TextView
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/done"
android:id="@+id/done_profile_btn"
android:textColor="@color/white"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:id="@+id/input_profile_swift"
android:hint="@string/swift"
android:inputType="textCapCharacters"
android:textColor="@color/colorPrimaryDark"
android:layout_marginBottom="22dp"
android:maxLines="1"
android:imeOptions="actionDone"/>
我想更改按键盘上的“完成”按钮对 EditText 执行的操作,以便执行与 TextView 相同的操作,后者执行以下操作:
done_btn = (TextView) findViewById(R.id.done_profile_btn);
swift = (EditText)findViewById(R.id.input_profile_swift);
done_btn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
//saveChanges();
//finish();
Toast.makeText(getApplicationContext(), "Your changes have been saved", Toast.LENGTH_SHORT).show();
}
});
...
所以...我希望两者(按键盘上的“完成”并按 TextView)执行相同的操作。
知道如何做到这一点吗?非常感谢。
最佳答案
您也可以使用这个(设置在 EditText 上执行操作时调用的特殊监听器),它适用于 DONE 和 RETURN:
swift.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
//saveChanges();
//finish();
Toast.makeText(getApplicationContext(), "Your changes have been saved", Toast.LENGTH_SHORT).show();
}
return false;
}
});
希望对你有帮助!
关于java - 更改 "imeOptions"(Android) 的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35405686/
我尝试将 android:imeOptions 设置为 actionSend、actionSearch。但是键盘上没有“发送”或“搜索”按钮,只有普通的“Enter”键。我还尝试设置不同的输入类型。
我有典型的登录屏幕。我能够使用 imeOptions 允许用户从一个字段“tab”到另一个字段,在最后一个字段(密码)上我有 actionDone - 它只是关闭软键盘。理想情况下,我喜欢自动点击“登
我有 FrameLayout 容器,我想在其中动态添加 EditText。我需要同时设置两个 imeOptions:IME_ACTION_DONE 和 IME_FLAG_NO_EXTRACT_UI 但
我有两个基于单选按钮更改事件的 EditText txtPassword、txtEmail 我只是隐藏和显示 txtPassword 字段我只想用 porgrammatic 更改 ImeOptions
我在布局中有 2 个 id 为 (et_1 and et_2) 的 EditText,我设置了 对于 et_1 android:imeOptions="actionNext", android:nex
我有一个包含 EditText 的 fragment ,我正在尝试设置键盘事件,但它似乎不起作用。 actionId 始终为 0。 name.setOnEditorActionListener(ne
我在 HTC 设备上看不到像 done 和 like 这样的 imeoptions,而相同的代码在摩托罗拉上运行良好。 这是代码
有了按钮就很简单了 这将执行 doSomething(View) 函数。 我们怎样才能用 EditText 模仿这个?我已经读到过这个,我读到大多数人使用 imeOptions(这似乎仍然是必要的)
我有一个带有具有以下属性的 EditText 的应用程序: 在我运行 Froyo 的手机上,我的键盘上有“发送”操作按钮,android:imeOptions="actionSend" 应该这样做,
我正在尝试获取 Android 应用程序的登录屏幕,到目前为止这是我的代码:
我有一个 EditText 我正在设置以下属性,以便当用户单击 EditText 时我可以在键盘上显示完成按钮。 editText.setImeOptions(EditorInfo.IME_ACTIO
伙计们,这就是我现在的问题。 我有下一个 TextView 和 EditText activity_profile.xml 我想更改按键盘上的“完成”按钮对 EditText 执行的操作,以便执行
我需要在密码字段中分配操作按钮以登录。这是我尝试过的: XML: Java: etPassword = (EditText)view.findViewById(R.id.password); e
是否可以在 Android xml 中使用超过 1 个 imeOptions?对于相同的文本字段。 例如 现在它给我一个错误,说 1 imeOptions 已经被使用,我不能再使用了 最佳答案 使用
我遇到了麻烦。我正在使用 Google Maps Api v2,我创建了一个基本的工具栏,就像在 Google Maps App 中一样。我上面有一个 AutoCompleteTextBox。 问题是
我有一个 EditText,其 ImeOptions 设置为 EditorInfo.IME_ACTION_NEXT。因此,当该字段获得焦点时,“下一步”按钮将显示在键盘上。我希望按钮在用户键入时更改为
我有一个编辑文本。它包含属性数字和 imeOptions (actionDone)。 同时使用 digit && imeOptions 属性时未找到 actionDone(Softkeyword 中
我想知道是否可以将搜索按钮上的放大镜更改为文本“搜索”。我们希望将 imeOptions 设置保留为 android:imeOptions="actionSearch"因为我们响应某个事件。 这是我的
我正在使用 imeOptions,它们运行良好。但是,我有一个 ExpandableListView,其中一个子项是具有 3 个 EditText 的布局,而 imeOptions 甚至没有显示这些内
在布局 XML 中,可以指定 android:imeOptions="actionNext" 在虚拟键盘中添加 Next 按钮并单击它 - 焦点跳转到下一个字段。 如何以编程方式执行此操作 - 例如基
我是一名优秀的程序员,十分优秀!