本文整理匯總了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;
}