为android编写字典应用程序.想要根据当前输入语言设置翻译方向(更准确地说,软键盘上显示的字母语言).例如,我们得到了英语 - 法语的语言对.我想要的是,当用户输入英文字母(显示英文键盘布局)时,翻译方向是直的,当键盘布局改为法语时,翻译方向也会改变为倒置.
所以,问题是:在Android输入法框架中是否有任何事件,它允许跟踪这种布局的变化.如果没有,也许有一些标准的技巧来做我需要的?
先谢谢你,Alex
android keyboard-layout keyboard-events android-input-method
我正在开发一个Android 输入法,我想我的键盘工作只有"平移和扫描"和"调整"的模式,而不是在"全屏"(如解释在这里),或至少要求比较喜欢"调整大小"模式.我知道有一种方法可以从EditText设置它,但我如何从IME请求它?有没有我可以调用onStartInputView事件的方法?或者android系统如何决定IME使用哪种模式?
在横向模式下的其中一个音符应用程序中,默认IME不使用全屏模式,但我的是,所以应该有一些我无法找到的东西:S.也许它会检查键盘的高度?如果有,怎么样?我很感激任何想法,谢谢!
android landscape ime android-input-method android-inputtype
https://github.com/facebook/react-native/issues/7762
我正在尝试在Android上使用React-Native构建自定义键盘.它们是用InputMethodService实现的,因此很难提供一个rnplay.我已经跟踪了DialogModule.class文件中的以下代码
public void onHostResume() {
this.mIsInForeground = true;
DialogModule.FragmentManagerHelper fragmentManagerHelper = this.getFragmentManagerHelper();
Assertions.assertNotNull(fragmentManagerHelper, "Attached DialogModule to host with pending alert but no FragmentManager (not attached to an Activity).");
fragmentManagerHelper.showPendingAlert();
}
@Nullable
private DialogModule.FragmentManagerHelper getFragmentManagerHelper() {
Activity activity = this.getCurrentActivity();
return activity == null?null:(activity instanceof FragmentActivity?new DialogModule.FragmentManagerHelper(((FragmentActivity)activity).getSupportFragmentManager()):new DialogModule.FragmentManagerHelper(activity.getFragmentManager()));
}
Run Code Online (Sandbox Code Playgroud)
以下是我如何设置SimpleIME
package com.customKeyboard;
import android.content.Context;
import android.inputmethodservice.InputMethodService;
import android.inputmethodservice.Keyboard;
import android.inputmethodservice.KeyboardView;
import android.media.AudioManager;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import com.facebook.react.LifecycleState;
import com.facebook.react.ReactInstanceManager; …Run Code Online (Sandbox Code Playgroud) android android-input-method react-native react-native-android
我试图为Android创建一个不是传统键盘的IME(对应于不同字母的键行),我无法找到有关如何操作的有用资源,因为SDK中的所有代码示例都使用了Keyboard API它内置于功能中.
我在XML文件中设计了IME的界面,好像它只是应用程序中的一个Activity,但我在他们的演示中迷失了,因为他们的键盘只是从不同风格的XML结构构建的对象.
如果有人链接到一个不使用传统键盘结构的开源项目,或者只是引导我显示我已经构建到IME窗口上的UI,我想我可以想出其余部分.
如果您需要更多特定信息,请随时提出.提前致谢.
我在屏幕键盘上遇到了麻烦.我有一个EditText显示键盘的活动,以及一个进入第二个活动的按钮.第二个活动显示了ProgressDialog它onCreate(),做了什么,并解散了ProgressDialog.问题是ProgressDialog显示时,键盘也是如此.
我希望键盘在创建之前消失ProgressDialog.我搜索了StackOverflow和其他网站,但似乎没有任何东西可以用于这个特定的场景.
我附上两张照片供你参考:
http://i45.tinypic.com/2rzq7b6.png http://i45.tinypic.com/34ret1z.png
这是第一个活动的代码:
public class FirstActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findViewById(R.id.button1).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
startActivity(intent);
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
这是第二个活动的代码:
public class SecondActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
// TODO: hide keyboard here
final ProgressDialog dialog = ProgressDialog.show(this, "", "Please wait...", …Run Code Online (Sandbox Code Playgroud) android dialog progressdialog android-input-method android-activity
问题的简短版本:如何在Android中的软输入/键盘上捕获长按事件?
长版:在Android应用程序中,我们有一个多行EditText,我们希望有这样的行为:1.默认情况下,它显示一个DONE按钮,通过点击它,软输入/键盘将被关闭.2.如果用户长按DONE按钮,其行为将更改为ENTER按钮,EditText中将有一个新行.
对于需求#1,我在这里使用了解决方案:https://stackoverflow.com/a/12570003/4225326
对于需求#2,我遇到的阻塞问题是,如何捕获长按事件.我设置了onEditorActionListener,但捕获的事件为null:http://developer.android.com/reference/android/widget/TextView.OnEditorActionListener.html 我搜索了文档,长按相关的方法是针对硬键盘:http:http: //developer.android.com/reference/android/view/View.html#onKeyLongPress(int,android.view.KeyEvent),我找不到一个用于软输入/键盘.
感谢您查看此问题.
我想用我的Android自定义键盘用enter键搜索,但它不起作用.
我已经映射了密钥,我只需要在搜索文本字段上触发"搜索操作",就像在Google上搜索一样.
我尝试使用此代码来触发搜索操作,但它不起作用:
ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
Run Code Online (Sandbox Code Playgroud)
这是我覆盖enter键事件的方法:
public class Keyboard extends InputMethodService
implements KeyboardView.OnKeyboardActionListener {
@Override
public void onStartInputView(EditorInfo info, boolean restarting) {
super.onStartInputView(info, restarting);
setInputView(onCreateInputView());
switch (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION) {
case EditorInfo.IME_ACTION_SEARCH:
Toast.makeText(this, "test", Toast.LENGTH_SHORT).show();
//Action Search
break;
}
}
Run Code Online (Sandbox Code Playgroud)
我的xml布局是:
<?xml version="1.0" encoding="UTF-8"?>
<android.inputmethodservice.KeyboardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keyboard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:keyPreviewHeight="60dp"
android:keyPreviewOffset="12dp"
android:keyPreviewLayout="@layout/preview"
android:visibility="visible"/>
Run Code Online (Sandbox Code Playgroud)
我的布局中没有任何EditText可供设置android:imeOptions="actionSearch".
keyboard android keyevent android-softkeyboard android-input-method
我正在为Android开发软键盘。我想使用 InputConnection.commitCorrecrion() 更正一些文本,如果按下与 Keyboard.KEYCODE_DONE 相对应的键。但是,文本不会改变,只是闪烁一次。我怎么解决这个问题?
public class SimpleIME extends InputMethodService
implements KeyboardView.OnKeyboardActionListener {
....
@Override
public void onKey(int primaryCode, int[] keyCodes) {
InputConnection ic = getCurrentInputConnection();
switch(primaryCode){
....
case Keyboard.KEYCODE_DONE:
ic.commitCorrection(new CorrectionInfo(oldTextPosition, oldText, newText));
break;
....
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试设计自定义键盘,键盘的一部分是允许用户选择一些文本并进行编辑.我希望为用户提供能够切换锚点选择的能力,以便他/她能够从选择的任一端扩展/缩小选择.
直到现在我已经传递了简单的ctrl-a/shift-arrow键以允许用户这样做,但是使用这种方法我无法切换选择锚点,我所知道的都没有.
我试图在android api中使用Selection类,但无济于事.我最初想过交换Selection.SELECT_END和Selection.SELECT_START变量可能会做的伎俩,但后来我意识到这些是最终变量,因此是一个死胡同.setSelection(Spannable text, int start, int stop)在Selection类中有一个命名的方法,但是我无法理解参数"Spannable text".它是什么?我从哪里得到它?
所以问题是,我怎样才能实现这一目标?
我正在开发的键盘是开源的,如果你需要检查代码以理解问题的任何部分,你可以在这里访问代码
我需要开发 Android 键盘应用程序,但 Android 开发人员网站告诉我,在 Api 29 之后,不推荐KeyboardView使用Keybord类来创建键盘的 UI。
此类在 API 级别 29 中已弃用。以下是我发现的消息:
此类已被弃用,因为这只是一个方便的 UI 小部件类,应用程序开发人员可以在现有公共 API 之上重新实现。如果您已经依赖于此类,请考虑将 AOSP 的实现复制到您的项目中或自己重新实现类似的小部件
那么,如果 Api 29 之后类无法运行,我该如何开发应用程序呢?有什么建议吗?
android uikeyboard input-method-kit android-softkeyboard android-input-method
android ×10
ime ×3
dialog ×1
keyboard ×1
keyevent ×1
landscape ×1
react-native ×1
uikeyboard ×1
xml ×1