我正在使用拨号盘作为Android手机上的原生拨号盘。而不是软键盘我给了按钮(1,2,..... *,#)。这就是为什么我需要光标可见性和软键盘隐藏。
在我的应用程序中,我创建了自己的拨号盘,其中包含用于显示印刷机数字输入和按钮的编辑文本。我使用以下选项
隐藏了edittext的软键盘 dialText.setInputType(InputType.TYPE_NULL);
我正在运行2.3.x及其以下版本的代码,它使用拨号edittext 显示编辑文本上的光标。但是如果在 sdk 4.0版上运行上面的代码,它就不会显示光标。我的问题是我需要在所有Android版设备的edittext上显示光标。怎么做?请帮帮我。
隐藏我正在使用的软键盘:
dialText.setInputType(InputType.TYPE_NULL); // hide soft key board
我的编辑文字xml:
<EditText
android:id="@+id/dialText"
android:layout_width="match_parent"
android:layout_marginTop="15dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="center"
android:singleLine="true"
android:layout_height="wrap_content"
android:ems="10" >
</EditText>
答案 0 :(得分:0)
android:cursorVisible="true"
我认为这就是你要找的东西!
答案 1 :(得分:0)
尝试使用onCreate()方法隐藏键盘。
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
试试这段代码。
yourEditTextHere.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// NOTE: In the author's example, he uses an identifier
// called searchBar. If setting this code on your EditText
// then use v.getWindowToken() as a reference to your
// EditText is passed into this callback as a TextView
in.hideSoftInputFromWindow(yourEditTextHere
.getApplicationWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
// Must return true here to consume event
return true;
}
});