Java Code Examples for android.view.FocusFinder#getInstance()
The following examples show how to use
android.view.FocusFinder#getInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TabHorizontalGridView.java From LeanbackTvSample with MIT License | 6 votes |
@Override public View focusSearch(View focused, int direction) { if (focused != null) { final FocusFinder ff = FocusFinder.getInstance(); final View found = ff.findNextFocus(this, focused, direction); if (direction == View.FOCUS_LEFT || direction == View.FOCUS_RIGHT) { if ((found == null || found.getId() != R.id.tv_main_title) && getScrollState() == SCROLL_STATE_IDLE) { if (shakeX == null) { shakeX = AnimationUtils.loadAnimation(getContext(), R.anim.host_shake); } focused.clearAnimation(); focused.startAnimation(shakeX); return null; } } } return super.focusSearch(focused, direction); }
Example 2
Source File: Focus2AndroidTest.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
@Override protected void setUp() throws Exception { super.setUp(); mFocusFinder = FocusFinder.getInstance(); // inflate the layout final Context context = getContext(); final LayoutInflater inflater = LayoutInflater.from(context); mRoot = (ViewGroup) inflater.inflate(R.layout.focus_2, null); // manually measure it, and lay it out mRoot.measure(500, 500); mRoot.layout(0, 0, 500, 500); mLeftButton = (Button) mRoot.findViewById(R.id.leftButton); mCenterButton = (Button) mRoot.findViewById(R.id.centerButton); mRightButton = (Button) mRoot.findViewById(R.id.rightButton); }
Example 3
Source File: DpadAwareRecyclerView.java From dpad-aware-recycler-view with Apache License 2.0 | 5 votes |
/** * Request natural focus. * * @param direction direction in which focus is changing * @param previouslyFocusedRect previously focus rectangle */ private void requestNaturalFocus(int direction, Rect previouslyFocusedRect) { FocusFinder ff = FocusFinder.getInstance(); previouslyFocusedRect = previouslyFocusedRect == null ? new Rect(0, 0, 0, 0) : previouslyFocusedRect; View toFocus = ff.findNextFocusFromRect(this, previouslyFocusedRect, direction); toFocus = toFocus == null ? getChildAt(0) : toFocus; if (toFocus != null) { toFocus.requestFocus(); } }