本文整理了Java中android.widget.Button.isFocused()
方法的一些代码示例,展示了Button.isFocused()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.isFocused()
方法的具体详情如下:
包路径:android.widget.Button
类名称:Button
方法名:isFocused
暂无
代码示例来源:origin: MoMoWait/LeanbackLauncher
public boolean dispatchKeyEvent(KeyEvent event) {
int action = event.getAction();
int keyCode = event.getKeyCode();
if (action == 0) {
if (keyCode == 19 && this.mFinishButton.isFocused()) {
notifyOnFocusLeavingEditMode(0);
} else if ((keyCode == 19 && this.mUninstallIcon.isFocused()) || (keyCode == 4 && this.mUninstallIcon.isFocused())) {
notifyOnFocusLeavingEditMode(1);
} else if ((Util.isConfirmKey(keyCode) || keyCode == 4) && this.mFinishButton.isFocused()) {
notifyOnExitEditModeTriggered();
} else if (Util.isConfirmKey(keyCode) && this.mUninstallIcon.isFocused()) {
this.mUninstallListener.onUninstallPressed(notifyPrepForUninstall());
}
return true;
} else if (action == 1) {
return true;
} else {
return super.dispatchKeyEvent(event);
}
}
代码示例来源:origin: rockon999/LeanbackLauncher
public boolean dispatchKeyEvent(KeyEvent event) {
int action = event.getAction();
int keyCode = event.getKeyCode();
if (action == 0) {
if (keyCode == 19 && this.mFinishButton.isFocused()) {
notifyOnFocusLeavingEditMode(0);
return true;
} else if ((keyCode == 19 && this.mUninstallIcon.isFocused()) || (keyCode == 4 && this.mUninstallIcon.isFocused())) {
notifyOnFocusLeavingEditMode(1);
return true;
} else if ((Util.isConfirmKey(keyCode) || keyCode == 4) && this.mFinishButton.isFocused()) {
notifyOnExitEditModeTriggered();
return true;
} else if (!Util.isConfirmKey(keyCode) || !this.mUninstallIcon.isFocused()) {
return true;
} else {
this.mUninstallListener.onUninstallPressed(notifyPrepForUninstall());
return true;
}
} else if (action != 1) {
return super.dispatchKeyEvent(event);
} else {
return true;
}
}
代码示例来源:origin: THEONE10211024/ApiDemos
@MediumTest
public void testGoingRightFromLeftButtonJumpsOverCenterToRight() {
sendKeys(KeyEvent.KEYCODE_DPAD_RIGHT);
assertTrue("right button should be focused", mRightButton.isFocused());
}
代码示例来源:origin: qiubiteme/android_api_demos
@MediumTest
public void testGoingRightFromLeftButtonJumpsOverCenterToRight() {
sendKeys(KeyEvent.KEYCODE_DPAD_RIGHT);
assertTrue("right button should be focused", mRightButton.isFocused());
}
代码示例来源:origin: THEONE10211024/ApiDemos
@MediumTest
public void testGoingLeftFromRightButtonGoesToCenter() {
// Give right button focus by having it request focus. We post it
// to the UI thread because we are not running on the same thread, and
// any direct api calls that change state must be made from the UI thread.
// This is in contrast to instrumentation calls that send events that are
// processed through the framework and eventually find their way to
// affecting the ui thread.
getActivity().runOnUiThread(new Runnable() {
public void run() {
mRightButton.requestFocus();
}
});
// wait for the request to go through
getInstrumentation().waitForIdleSync();
assertTrue(mRightButton.isFocused());
sendKeys(KeyEvent.KEYCODE_DPAD_LEFT);
assertTrue("center button should be focused", mCenterButton.isFocused());
}
}
代码示例来源:origin: qiubiteme/android_api_demos
@MediumTest
public void testGoingLeftFromRightButtonGoesToCenter() {
// Give right button focus by having it request focus. We post it
// to the UI thread because we are not running on the same thread, and
// any direct api calls that change state must be made from the UI thread.
// This is in contrast to instrumentation calls that send events that are
// processed through the framework and eventually find their way to
// affecting the ui thread.
getActivity().runOnUiThread(new Runnable() {
public void run() {
mRightButton.requestFocus();
}
});
// wait for the request to go through
getInstrumentation().waitForIdleSync();
assertTrue(mRightButton.isFocused());
sendKeys(KeyEvent.KEYCODE_DPAD_LEFT);
assertTrue("center button should be focused", mCenterButton.isFocused());
}
}
代码示例来源:origin: qiubiteme/android_api_demos
/**
* The name 'test preconditions' is a convention to signal that if this
* test doesn't pass, the test case was not set up properly and it might
* explain any and all failures in other tests. This is not guaranteed
* to run before other tests, as junit uses reflection to find the tests.
*/
@MediumTest
public void testPreconditions() {
assertTrue("center button should be right of left button",
mLeftButton.getRight() < mCenterButton.getLeft());
assertTrue("right button should be right of center button",
mCenterButton.getRight() < mRightButton.getLeft());
assertTrue("left button should be focused", mLeftButton.isFocused());
}
代码示例来源:origin: THEONE10211024/ApiDemos
/**
* The name 'test preconditions' is a convention to signal that if this
* test doesn't pass, the test case was not set up properly and it might
* explain any and all failures in other tests. This is not guaranteed
* to run before other tests, as junit uses reflection to find the tests.
*/
@MediumTest
public void testPreconditions() {
assertTrue("center button should be right of left button",
mLeftButton.getRight() < mCenterButton.getLeft());
assertTrue("right button should be right of center button",
mCenterButton.getRight() < mRightButton.getLeft());
assertTrue("left button should be focused", mLeftButton.isFocused());
}
内容来源于网络,如有侵权,请联系作者删除!