Java Code Examples for android.view.View.setFocusableInTouchMode()

The following are Jave code examples for showing how to use setFocusableInTouchMode() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: backstack   File: Helper.java   Source Code and License Vote up 7 votes
/**
 * 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);
}
 
Example 2
Project: EasyTodo   File: EventContentActivity.java   Source Code and License Vote up 7 votes
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;
    }
 
Example 3
Project: GmArchMvvm   File: KeyboardUtils.java   Source Code and License Vote up 6 votes
/**
 * 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);
}
 
Example 4
Project: letv   File: BasicActivity.java   Source Code and License Vote up 6 votes
public void setViewFocus(View view) {
    if (view != null) {
        view.setFocusable(true);
        view.setFocusableInTouchMode(true);
        view.requestFocus();
        view.requestFocusFromTouch();
    }
}
 
Example 5
Project: TPlayer   File: TDevice.java   Source Code and License Vote up 6 votes
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);
}
 
Example 6
Project: GitHub   File: SoftInputUtils.java   Source Code and License Vote up 5 votes
/**
 * 弹出输入法
 *
 * @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);
}
 
Example 7
Project: GitHub   File: KeyboardUtils.java   Source Code and License Vote up 5 votes
/**
 * 动态显示软键盘
 *
 * @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);
}
 
Example 8
Project: EasyEmoji   File: KeyboardManagerImpl.java   Source Code and License Vote up 5 votes
@Override
public void openKeyboard(View view) {
    if(mInputManager != null) {
        view.setFocusableInTouchMode(true);
        view.requestFocus();
        mInputManager.showSoftInput(view, InputMethodManager.SHOW_FORCED);
    }
}
 
Example 9
Project: SlotNSlot_Android   File: SlotBankerFragment.java   Source Code and License Vote up 5 votes
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;
    });
}
 
Example 10
Project: FlickLauncher   File: LauncherAppWidgetHostView.java   Source Code and License Vote up 5 votes
@Override
public void requestChildFocus(View child, View focused) {
    super.requestChildFocus(child, focused);
    dispatchChildFocus(mChildrenFocused && focused != null);
    if (focused != null) {
        focused.setFocusableInTouchMode(false);
    }
}
 
Example 11
Project: MVVMArms   File: KeyboardUtils.java   Source Code and License Vote up 5 votes
/**
 * 动态显示软键盘
 *
 * @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);
}
 
Example 12
Project: SimpleUILauncher   File: LauncherAppWidgetHostView.java   Source Code and License Vote up 5 votes
@Override
public void requestChildFocus(View child, View focused) {
    super.requestChildFocus(child, focused);
    dispatchChildFocus(mChildrenFocused && focused != null);
    if (focused != null) {
        focused.setFocusableInTouchMode(false);
    }
}
 
Example 13
Project: quickhybrid-android   File: DeviceUtil.java   Source Code and License Vote up 5 votes
/**
 * 弹出键盘
 *
 * @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);
}
 
Example 14
Project: android-util2   File: ViewUtil.java   Source Code and License Vote up 5 votes
/**
 * 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();
    }
}
 
Example 15
Project: PlayAndroid   File: KeyBoardUtil.java   Source Code and License Vote up 5 votes
/**
 * 动态显示软键盘
 * {@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);
}
 
Example 16
Project: ModuleFrame   File: KeyboardUtil.java   Source Code and License Vote up 5 votes
/**
 * 动态显示软键盘
 *
 * @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);
}
 
Example 17
Project: SuperNote   File: FolderPresenter.java   Source Code and License Vote up 5 votes
public void setFoucus(View view){
//        获取 接受焦点的资格
        view.setFocusable(true);
//        获取 焦点可以响应点触的资格
        view.setFocusableInTouchMode(true);
//        请求焦点
        view.requestFocus();
//        弹出键盘
        InputMethodManager manager=(InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        manager.toggleSoftInput(0,0);
        manager.showSoftInput(view,0);
    }
 
Example 18
Project: SuperNote   File: RvEditFolderAdapter.java   Source Code and License Vote up 5 votes
public void setFoucus(View view){
//        获取 接受焦点的资格
        view.setFocusable(true);
//        获取 焦点可以响应点触的资格
        view.setFocusableInTouchMode(true);
//        请求焦点
        view.requestFocus();
//        弹出键盘
        InputMethodManager manager=(InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        manager.toggleSoftInput(0,0);
        manager.showSoftInput(view,0);
    }
 
Example 19
Project: DizzyPassword   File: KeyboardUtils.java   Source Code and License Vote up 5 votes
/**
 * 动态显示软键盘
 *
 * @param view 视图
 */
public static void showSoftInput(final View view, Context context) {
    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);
}
 
Example 20
Project: GravityBox   File: VolumePreference.java   Source Code and License Vote up 5 votes
@Override
protected void onBindDialogView(View view) {
    super.onBindDialogView(view);
    final SeekBar seekBar = (SeekBar) view.findViewById(R.id.seekbar);
    mSeekBarVolumizer = new SeekBarVolumizer(getContext(), seekBar, mStreamType);

    // grab focus and key events so that pressing the volume buttons in the
    // dialog doesn't also show the normal volume adjust toast.
    view.setOnKeyListener(this);
    view.setFocusableInTouchMode(true);
    view.requestFocus();
}