本文整理汇总了Java中android.view.View.isFocused方法的典型用法代码示例。如果您正苦于以下问题:Java View.isFocused方法的具体用法?Java View.isFocused怎么用?Java View.isFocused使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.isFocused方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onKeyDown
import android.view.View; //导入方法依赖的package包/类
/**
* 顶部焦点获取
*
* @param keyCode
* @param event
* @return
*/
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
boolean focusFlag = false;
for (View v : mViews) {
if (v.isFocused()) {
focusFlag = true;
}
}
Log.d(TAG, "code:" + keyCode + " flag:" + focusFlag);
if (focusFlag) {
if (KeyEvent.KEYCODE_DPAD_LEFT == keyCode) {
if (mCurrentIndex > 0) {
mViews[--mCurrentIndex].requestFocus();
}
return true;
} else if (KeyEvent.KEYCODE_DPAD_RIGHT == keyCode) {
if (mCurrentIndex < 2) {
mViews[++mCurrentIndex].requestFocus();
}
return true;
}
}
return super.onKeyDown(keyCode, event);
}
示例2: onClick
import android.view.View; //导入方法依赖的package包/类
@Override
public void onClick(final View v) {
if (!v.isFocused()) {
v.setFocusable(true);
v.setFocusableInTouchMode(true);
v.requestFocus();
GuiUtils.setKeypadVisibility(getActivity(), (EditText)v, View.VISIBLE);
// 這裡會先delay再送出event,要不然softkeyboard不會出現
/*(new Handler()).postDelayed(new Runnable() {
public void run() {
v.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN , 0, 0, 0));
v.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP , 0, 0, 0));
}
}, 200);*/
}
}
示例3: findFocusedView
import android.view.View; //导入方法依赖的package包/类
private View findFocusedView() {
for (View v : mTrackedViews) {
if (v.isFocused()) {
return v;
}
}
return null;
}
示例4: onLayoutChange
import android.view.View; //导入方法依赖的package包/类
@Override
public void onLayoutChange(View view, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (view.isFocused() && view instanceof TextView) {
// A focused view changed its bounds. Follow it?
int height = bottom - top;
int oldHeight = oldBottom - oldTop;
if (oldHeight != height) {
zoomToView(view, false);
}
} else {
view.removeOnLayoutChangeListener(this);
}
}
示例5: showSoftKeyboard
import android.view.View; //导入方法依赖的package包/类
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);
}
示例6: hasFocusedChild
import android.view.View; //导入方法依赖的package包/类
private static boolean hasFocusedChild(View view) {
if (view.isFocused())
return true;
if (view instanceof ViewGroup) {
ViewGroup group = (ViewGroup) view;
for (int i = 0; i < group.getChildCount(); i++) {
if (hasFocusedChild(group.getChildAt(i)))
return true;
}
}
return false;
}
示例7: showSoftKeyboard
import android.view.View; //导入方法依赖的package包/类
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);
}
示例8: arrowScroll
import android.view.View; //导入方法依赖的package包/类
public boolean arrowScroll(int direction) {
View currentFocused = findFocus();
if (currentFocused == this) {
currentFocused = null;
}
View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction);
int maxJump = getMaxScrollAmount();
if (nextFocused == null || !isWithinDeltaOfScreen(nextFocused, maxJump, getHeight())) {
int scrollDelta = maxJump;
if (direction == 33 && getScrollY() < scrollDelta) {
scrollDelta = getScrollY();
} else if (direction == 130 && getChildCount() > 0) {
int daBottom = getChildAt(0).getBottom();
int screenBottom = (getScrollY() + getHeight()) - getPaddingBottom();
if (daBottom - screenBottom < maxJump) {
scrollDelta = daBottom - screenBottom;
}
}
if (scrollDelta == 0) {
return false;
}
int i;
if (direction == 130) {
i = scrollDelta;
} else {
i = -scrollDelta;
}
doScrollY(i);
} else {
nextFocused.getDrawingRect(this.mTempRect);
offsetDescendantRectToMyCoords(nextFocused, this.mTempRect);
doScrollY(computeScrollDeltaToGetChildRectOnScreen(this.mTempRect));
nextFocused.requestFocus(direction);
}
if (currentFocused != null && currentFocused.isFocused() && isOffScreen(currentFocused)) {
int descendantFocusability = getDescendantFocusability();
setDescendantFocusability(131072);
requestFocus();
setDescendantFocusability(descendantFocusability);
}
return true;
}