紧急拨号盘在androidmanifest中设置了windowSoftInputMode="stateAlways...
时间:10-02
整理:3721RD
点击:
紧急拨号盘在androidmanifest 中设置了android:windowSoftInputMode="state Always Hidden" 不起作用
[DESCRIPTION]
为了紧急拨号盘可以在中间输入电话号码,在在Layout文件中设置了android:focusbale In touch Mode="true" 后,同时在android manifest中设置了android:window Soft In put Mode="stateAlwaysHidden".
但是在紧急拨号盘还是会弹出虚拟键盘。
[SOLUTION]
设置android:focusbaleInTouchMode="true"这个属性后,windowSoftInputMode
AP 的这个属性被动态改写了,所以该问题可以参考联系人里的解决方法,
写一个DigitsEditText的类继承自EditText,
重载下面两个方法,
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
super.onFocusChanged(focused, direction, previouslyFocusedRect);
final InputMethoDMAnager imm = ((InputMethodManager) getContext()
.getSystEMService(Context.INPUT_METHOD_SERVICE));
if (imm != null && imm.isActive(this)) {
imm.hideSoftInputFROMWindow(getApplicationWindowToken(), 0);
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
final boolean ret = super.onTouchEvent(event);
// Must be done after super.onTouchEvent()
final InputMethodManager imm = ((InputMethodManager) getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE));
if (imm != null && imm.isActive(this)) {
imm.hideSoftInputFromWindow(getApplicationWindowToken(), 0);
}
return ret;
}
然后在emergency_dialer.xml中将
<EditText
android:id="@+id/digits"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center"
android:scrollHorizontally="true"
android:textAppearance="@style/DialtactsDigitsTextAppearance"
android:focusableInTouchMode="false"
android:nextFocusRight="@+id/deleteButton"
android:background="@android:color/transparent" />
修改为
<xx.xx.DigitsEditText
android:id="@+id/digits"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center"
android:scrollHorizontally="true"
android:textAppearance="@style/DialtactsDigitsTextAppearance"
android:focusableInTouchMode="false"
android:nextFocusRight="@+id/deleteButton"
android:focusbaleInTouchMode="true"
android:background="@android:color/transparent" />
注意
xx.xx.DigitsEditText是DigitsEditText完整的类名.
[DESCRIPTION]
为了紧急拨号盘可以在中间输入电话号码,在在Layout文件中设置了android:focusbale In touch Mode="true" 后,同时在android manifest中设置了android:window Soft In put Mode="stateAlwaysHidden".
但是在紧急拨号盘还是会弹出虚拟键盘。
[SOLUTION]
设置android:focusbaleInTouchMode="true"这个属性后,windowSoftInputMode
AP 的这个属性被动态改写了,所以该问题可以参考联系人里的解决方法,
写一个DigitsEditText的类继承自EditText,
重载下面两个方法,
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
super.onFocusChanged(focused, direction, previouslyFocusedRect);
final InputMethoDMAnager imm = ((InputMethodManager) getContext()
.getSystEMService(Context.INPUT_METHOD_SERVICE));
if (imm != null && imm.isActive(this)) {
imm.hideSoftInputFROMWindow(getApplicationWindowToken(), 0);
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
final boolean ret = super.onTouchEvent(event);
// Must be done after super.onTouchEvent()
final InputMethodManager imm = ((InputMethodManager) getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE));
if (imm != null && imm.isActive(this)) {
imm.hideSoftInputFromWindow(getApplicationWindowToken(), 0);
}
return ret;
}
然后在emergency_dialer.xml中将
<EditText
android:id="@+id/digits"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center"
android:scrollHorizontally="true"
android:textAppearance="@style/DialtactsDigitsTextAppearance"
android:focusableInTouchMode="false"
android:nextFocusRight="@+id/deleteButton"
android:background="@android:color/transparent" />
修改为
<xx.xx.DigitsEditText
android:id="@+id/digits"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center"
android:scrollHorizontally="true"
android:textAppearance="@style/DialtactsDigitsTextAppearance"
android:focusableInTouchMode="false"
android:nextFocusRight="@+id/deleteButton"
android:focusbaleInTouchMode="true"
android:background="@android:color/transparent" />
注意
xx.xx.DigitsEditText是DigitsEditText完整的类名.
学习学习
没看明白
借鉴一下
看不懂