本文整理汇总了Java中android.view.View.setFocusableInTouchMode方法的典型用法代码示例。如果您正苦于以下问题:Java View.setFocusableInTouchMode方法的具体用法?Java View.setFocusableInTouchMode怎么用?Java View.setFocusableInTouchMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.setFocusableInTouchMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: disable
import android.view.View; //导入方法依赖的package包/类
/**
* Helper function to disable a ViewGroup and all it's children. This draws a new view with z-ordering of integer max
* that consumes all touch events.
* @param viewGroup
*/
public static void disable(ViewGroup viewGroup){
View view = new View(viewGroup.getContext());
viewGroup.addView(view);
view.setTag(DISABLE);
ViewGroup.LayoutParams params = view.getLayoutParams();
params.height = MATCH_PARENT;
params.width = MATCH_PARENT;
view.setLayoutParams(params);
view.setClickable(true);
view.setFocusable(true);
view.setFocusableInTouchMode(true);
view.setBackgroundColor(Color.TRANSPARENT);
if (Build.VERSION.SDK_INT >= 21) {
view.setTranslationZ(Integer.MAX_VALUE);
}
viewGroup.bringChildToFront(view);
}
示例2: isShouldHideInput
import android.view.View; //导入方法依赖的package包/类
public boolean isShouldHideInput(View v, MotionEvent event) {
if (v != null && (v instanceof EditText)) {
int[] leftTop = {0, 0};
//获取输入框当前的location位置
v.getLocationInWindow(leftTop);
int left = leftTop[0];
int top = leftTop[1];
int bottom = top + v.getHeight();
int right = left + v.getWidth();
if (event.getX() > left && event.getX() < right
&& event.getY() > top && event.getY() < bottom) {
// 点击的是输入框区域,保留点击EditText的事件
return false;
} else {
//使EditText触发一次失去焦点事件
v.setFocusable(false);
// v.setFocusable(true); //这里不需要是因为下面一句代码会同时实现这个功能
v.setFocusableInTouchMode(true);
return true;
}
}
return false;
}
示例3: showSoftInput
import android.view.View; //导入方法依赖的package包/类
/**
* Dynamic display soft keyboard
*
* @param view view
*/
public static void showSoftInput(Context context, final View view) {
view.setFocusable(true);
view.setFocusableInTouchMode(true);
view.requestFocus();
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null)
return;
imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
}
示例4: setViewFocus
import android.view.View; //导入方法依赖的package包/类
public void setViewFocus(View view) {
if (view != null) {
view.setFocusable(true);
view.setFocusableInTouchMode(true);
view.requestFocus();
view.requestFocusFromTouch();
}
}
示例5: showSoftKeyboard
import android.view.View; //导入方法依赖的package包/类
public static void showSoftKeyboard(View view) {
if (view == null) {
return;
}
view.setFocusable(true);
view.setFocusableInTouchMode(true);
if (!view.isFocused()) {
view.requestFocus();
}
InputMethodManager inputMethodManager = (InputMethodManager) view.getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.showSoftInput(view, 0);
}
示例6: setEditFocusable
import android.view.View; //导入方法依赖的package包/类
/**
* 弹出输入法
*
* @param context context
* @param view 编辑控件
*/
public static void setEditFocusable(final Context context, final View view) {
view.setFocusableInTouchMode(true);
view.requestFocus();
InputMethodManager inputMethodManager = (InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.showSoftInput(view, 0);
}
示例7: showSoftInput
import android.view.View; //导入方法依赖的package包/类
/**
* 动态显示软键盘
*
* @param view 视图
*/
public static void showSoftInput(final View view) {
view.setFocusable(true);
view.setFocusableInTouchMode(true);
view.requestFocus();
InputMethodManager imm = (InputMethodManager) Utils.getApp().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null) return;
imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
}
示例8: openKeyboard
import android.view.View; //导入方法依赖的package包/类
@Override
public void openKeyboard(View view) {
if(mInputManager != null) {
view.setFocusableInTouchMode(true);
view.requestFocus();
mInputManager.showSoftInput(view, InputMethodManager.SHOW_FORCED);
}
}
示例9: onBackPressed
import android.view.View; //导入方法依赖的package包/类
private void onBackPressed(View view) {
view.setFocusableInTouchMode(true);
view.setOnKeyListener((v, keyCode, event) -> {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
new AlertDialog.Builder(getActivity())
.setTitle("Leave")
.setMessage("Exit the watch screen?")
.setPositiveButton("Yes", (dialog, id) -> getActivity().finish())
.setNegativeButton("No", null)
.show();
return true;
}
return false;
});
}
示例10: requestChildFocus
import android.view.View; //导入方法依赖的package包/类
@Override
public void requestChildFocus(View child, View focused) {
super.requestChildFocus(child, focused);
dispatchChildFocus(mChildrenFocused && focused != null);
if (focused != null) {
focused.setFocusableInTouchMode(false);
}
}
示例11: showSoftInput
import android.view.View; //导入方法依赖的package包/类
/**
* 动态显示软键盘
*
* @param view 视图
*/
public static void showSoftInput(Context context, final View view) {
view.setFocusable(true);
view.setFocusableInTouchMode(true);
view.requestFocus();
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null) {
return;
}
imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
}
示例12: showInputKeyboard
import android.view.View; //导入方法依赖的package包/类
/**
* 弹出键盘
*
* @param et
*/
public static void showInputKeyboard(View et) {
et.setFocusable(true);
et.setFocusableInTouchMode(true);
et.requestFocus();
InputMethodManager imm = (InputMethodManager) AppUtil.getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(et, 0);
}
示例13: obtainFocus
import android.view.View; //导入方法依赖的package包/类
/**
* request focus for target view
* @param v the target view.
*/
public static void obtainFocus(View v) {
if (v != null) {
v.setFocusable(true);
v.setFocusableInTouchMode(true);
v.requestFocus();
v.requestFocusFromTouch();
}
}
示例14: showSoftInput
import android.view.View; //导入方法依赖的package包/类
/**
* 动态显示软键盘
* {@link InputMethodManager#showSoftInput(View, int)}
*
* @param view 视图
*/
public static void showSoftInput(@NonNull View view) {
view.setFocusable(true);
view.setFocusableInTouchMode(true);
view.requestFocus();
getInputMethodManager().showSoftInput(view, InputMethodManager.SHOW_FORCED);
}
示例15: showSoftInput
import android.view.View; //导入方法依赖的package包/类
/**
* 动态显示软键盘
*
* @param context 上下文
* @param view 视图
*/
public static void showSoftInput(Context context, final View view) {
view.setFocusable(true);
view.setFocusableInTouchMode(true);
view.requestFocus();
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null) return;
imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
}