當前位置: 首頁>>代碼示例>>Java>>正文


Java View.isFocused方法代碼示例

本文整理匯總了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);
}
 
開發者ID:Evan-Galvin,項目名稱:FreeStreams-TVLauncher,代碼行數:32,代碼來源:MainActivity.java

示例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);*/
	}
}
 
開發者ID:Welloculus,項目名稱:MobileAppForPatient,代碼行數:18,代碼來源:MeterPreferenceDialog.java

示例3: findFocusedView

import android.view.View; //導入方法依賴的package包/類
private View findFocusedView() {
    for (View v : mTrackedViews) {
        if (v.isFocused()) {
            return v;
        }
    }
    return null;
}
 
開發者ID:sqrt1764,項目名稱:AndroidSoftKeyboardListener,代碼行數:9,代碼來源:SoftKeyboardListener.java

示例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);
    }
}
 
開發者ID:natario1,項目名稱:ViewPrinter,代碼行數:15,代碼來源:DocumentView.java

示例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);
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:11,代碼來源:TDevice.java

示例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;
}
 
開發者ID:MCMrARM,項目名稱:revolution-irc,代碼行數:13,代碼來源:LabelLayout.java

示例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);
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:15,代碼來源:TDevice.java

示例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;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:43,代碼來源:NestedScrollView.java


注:本文中的android.view.View.isFocused方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。