Example usage for android.view View requestFocus

List of usage examples for android.view View requestFocus

Introduction

In this page you can find the example usage for android.view View requestFocus.

Prototype

public final boolean requestFocus() 

Source Link

Document

Call this to try to give focus to a specific view or to one of its descendants.

Usage

From source file:Main.java

public static void obtainFocus(View v) {
    v.setFocusable(true);// w  w  w  . j  ava  2s.c om
    v.setFocusableInTouchMode(true);
    v.requestFocus();
    v.requestFocusFromTouch();
}

From source file:Main.java

public static void getFocus(View v) {
    v.setFocusable(true);/*from   www.  j a  v a 2s.co  m*/
    v.setFocusableInTouchMode(true);
    v.requestFocus();
    v.requestFocusFromTouch();
}

From source file:Main.java

public static void requestFocus(View view) {
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.requestFocus();
}

From source file:Main.java

public static void Focus(View view) {
    view.setFocusable(true);/*from www  .  j av  a  2s  . co m*/
    view.setFocusableInTouchMode(true);
    view.requestFocus();
    view.requestFocusFromTouch();
}

From source file:Main.java

public static void setFocus(View view) {
    view.setFocusable(true);/*ww  w  .  java2s.  com*/
    view.setFocusableInTouchMode(true);
    view.requestFocus();
    view.requestFocusFromTouch();
}

From source file:Main.java

/**
 * Force show soft keyboard with show flag = InputMethodManager.SHOW_FORCED and hide flag = 0.
 * @param context Context to get system service input method.
 * @param viewBinder View has current focus.
 *//*from   w w  w .j a v a 2 s . c om*/
public static void forceShowSoftInput(Context context, View view) {
    if (view != null) {
        view.requestFocus();
    }
    InputMethodManager inputManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); //Hide Flag = 0
}

From source file:Main.java

public static void showSoftInput(Context context, View view, boolean requestFocus) {
    if (requestFocus) {
        view.requestFocus();
    }/* w  ww . j av  a 2  s  .c  o  m*/
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Service.INPUT_METHOD_SERVICE);
    imm.showSoftInput(view, 0);
}

From source file:Main.java

public static void showKeyboard(Activity activity, View view) {
    if (activity != null) {
        if (view != null) {
            view.requestFocus();
        }/* www  . ja va 2  s.  c  o m*/
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
        }
    }
}

From source file:com.androzic.PreferencesHelpDialog.java

public static void scrollToView(final ScrollView scrollView, final View view) {
    view.requestFocus();

    final Rect scrollBounds = new Rect();
    scrollView.getHitRect(new Rect());
    if (!view.getLocalVisibleRect(scrollBounds)) {
        new Handler().post(new Runnable() {
            @Override/*from  w w  w .j a  v a2s . c o m*/
            public void run() {
                scrollView.smoothScrollTo(0, view.getBottom());
            }
        });
    }
}

From source file:Main.java

public static void requestFocusDelayed(final View view, long delayMillis) {
    view.postDelayed(new Runnable() {
        @Override//www.jav  a 2s. c  o m
        public void run() {
            view.requestFocus();
        }
    }, delayMillis);
}