Example usage for android.view View requestFocusFromTouch

List of usage examples for android.view View requestFocusFromTouch

Introduction

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

Prototype

public final boolean requestFocusFromTouch() 

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 disableAutoScrollToBottom(ScrollView scrollView) {
    scrollView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
    scrollView.setFocusable(true);//from   ww  w. ja  va  2 s .  c  o  m
    scrollView.setFocusableInTouchMode(true);
    scrollView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View arg0, MotionEvent arg1) {
            arg0.requestFocusFromTouch();
            return false;
        }
    });
}

From source file:Main.java

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

From source file:Main.java

public static void getFocus(View v) {
    v.setFocusable(true);//from   ww  w . j  a  v a  2s. c om
    v.setFocusableInTouchMode(true);
    v.requestFocus();
    v.requestFocusFromTouch();
}

From source file:Main.java

public static void Focus(View view) {
    view.setFocusable(true);/*from  w  w  w  . ja  v a 2  s  .c o m*/
    view.setFocusableInTouchMode(true);
    view.requestFocus();
    view.requestFocusFromTouch();
}

From source file:Main.java

public static void setFocus(View view) {
    view.setFocusable(true);/* w  w  w. ja v a  2s. co  m*/
    view.setFocusableInTouchMode(true);
    view.requestFocus();
    view.requestFocusFromTouch();
}

From source file:us.nineworlds.serenity.ui.browser.movie.MovieMenuDrawerOnItemClickedListener.java

private void playAllFromQueue(AdapterView<?> parent, SerenityMultiViewVideoActivity activity) {
    menuDrawer.closeDrawers();/*from  w ww  . j  a v  a 2s .c o m*/
    if (!activity.getPackageManager().hasSystemFeature("android.hardware.touchscreen")) {
        parent.setVisibility(View.INVISIBLE);
    }
    View gallery = activity.findViewById(R.id.moviePosterGallery);
    if (!activity.isGridViewActive()) {
        gallery.requestFocusFromTouch();
    } else {
        TwoWayGridView grid = (TwoWayGridView) activity.findViewById(R.id.movieGridView);
        grid.requestFocusFromTouch();
    }
    vpUtils.playAllFromQueue(activity);
}

From source file:us.nineworlds.serenity.ui.browser.tv.episodes.EpisodeBrowserActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    boolean menuKeySlidingMenu = prefs.getBoolean("remote_control_menu", true);
    if (menuKeySlidingMenu) {
        if (keyCode == KeyEvent.KEYCODE_MENU) {
            if (drawerLayout.isDrawerOpen(linearDrawerLayout)) {
                drawerLayout.closeDrawers();
            } else {
                drawerLayout.openDrawer(linearDrawerLayout);
            }/*from   w w  w  .j  a v a 2 s  .c  o m*/
            return true;
        }
    }

    if (keyCode == KeyEvent.KEYCODE_BACK && drawerLayout.isDrawerOpen(linearDrawerLayout)) {
        drawerLayout.closeDrawers();

        View gallery = findViewById(R.id.moviePosterGallery);
        if (gallery != null) {
            gallery.requestFocusFromTouch();
        }
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

From source file:com.df.kia.carsChecked.BasicInfoLayout.java

private void init(Context context, JSONObject procedures, String seriesId, String modelId) {
    rootView = (ViewGroup) LayoutInflater.from(context).inflate(R.layout.car_report_basic_layout, this);

    MyScrollView scrollView = (MyScrollView) findViewById(R.id.root);
    scrollView.setListener(new MyScrollView.ScrollViewListener() {
        @Override//from   w  ww.j  av  a2 s . c om
        public void onScrollChanged(MyScrollView scrollView, int x, int y, int oldx, int oldy) {
            if (scrollView.getScrollY() > 5) {
                showShadow(true);
            } else {
                showShadow(false);
            }
        }
    });

    // ??????
    scrollView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
    scrollView.setFocusable(true);
    scrollView.setFocusableInTouchMode(true);
    scrollView.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            v.requestFocusFromTouch();
            return false;
        }
    });

    try {
        fillInData(procedures, seriesId, modelId);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:com.todoroo.astrid.actfm.CommentsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    setHasOptionsMenu(true);//www  .ja  v a  2  s .co  m

    loadModelFromIntent(getActivity().getIntent());

    OnTouchListener onTouch = new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            v.requestFocusFromTouch();
            return false;
        }
    };

    if (!hasModel()) {
        getView().findViewById(R.id.updatesFooter).setVisibility(View.GONE);
    }

    addCommentField = (EditText) getView().findViewById(R.id.commentField);
    addCommentField.setOnTouchListener(onTouch);

    setUpUpdateList();
}

From source file:com.df.app.carsChecked.BasicInfoLayout.java

private void init(Context context, JSONObject procedures, String seriesId, String modelId) {
    rootView = (ViewGroup) LayoutInflater.from(context).inflate(R.layout.car_report_basic_layout, this);

    MyScrollView scrollView = (MyScrollView) findViewById(R.id.root);
    scrollView.setListener(new MyScrollView.ScrollViewListener() {
        @Override/*from w  ww .j av a  2s . c om*/
        public void onScrollChanged(MyScrollView scrollView, int x, int y, int oldx, int oldy) {
            if (scrollView.getScrollY() > 5) {
                showShadow(true);
            } else {
                showShadow(false);
            }
        }
    });

    // ??????
    scrollView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
    scrollView.setFocusable(true);
    scrollView.setFocusableInTouchMode(true);
    scrollView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            v.requestFocusFromTouch();
            return false;
        }
    });

    try {
        fillInData(procedures, seriesId, modelId);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}