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


Java View.setFocusableInTouchMode方法代碼示例

本文整理匯總了Java中android.view.View.setFocusableInTouchMode方法的典型用法代碼示例。如果您正苦於以下問題:Java View.setFocusableInTouchMode方法的具體用法?Java View.setFocusableInTouchMode怎麽用?Java View.setFocusableInTouchMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.View的用法示例。


在下文中一共展示了View.setFocusableInTouchMode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: disable

import android.view.View; //導入方法依賴的package包/類
/**
 * Helper function to disable a ViewGroup and all it's children. This draws a new view with z-ordering of integer max
 * that consumes all touch events.
 * @param viewGroup
 */
public static void disable(ViewGroup viewGroup){
    View view = new View(viewGroup.getContext());
    viewGroup.addView(view);
    view.setTag(DISABLE);

    ViewGroup.LayoutParams params = view.getLayoutParams();
    params.height = MATCH_PARENT;
    params.width = MATCH_PARENT;
    view.setLayoutParams(params);

    view.setClickable(true);
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(Color.TRANSPARENT);

    if (Build.VERSION.SDK_INT >= 21) {
        view.setTranslationZ(Integer.MAX_VALUE);
    }
    viewGroup.bringChildToFront(view);
}
 
開發者ID:kevinwang5658,項目名稱:backstack,代碼行數:26,代碼來源:Helper.java

示例2: isShouldHideInput

import android.view.View; //導入方法依賴的package包/類
public boolean isShouldHideInput(View v, MotionEvent event) {
        if (v != null && (v instanceof EditText)) {
            int[] leftTop = {0, 0};
            //獲取輸入框當前的location位置
            v.getLocationInWindow(leftTop);
            int left = leftTop[0];
            int top = leftTop[1];
            int bottom = top + v.getHeight();
            int right = left + v.getWidth();
            if (event.getX() > left && event.getX() < right
                    && event.getY() > top && event.getY() < bottom) {
                // 點擊的是輸入框區域,保留點擊EditText的事件
                return false;
            } else {
                //使EditText觸發一次失去焦點事件
                v.setFocusable(false);
//                v.setFocusable(true); //這裏不需要是因為下麵一句代碼會同時實現這個功能
                v.setFocusableInTouchMode(true);
                return true;
            }
        }
        return false;
    }
 
開發者ID:wendyltan,項目名稱:EasyTodo,代碼行數:24,代碼來源:EventContentActivity.java

示例3: showSoftInput

import android.view.View; //導入方法依賴的package包/類
/**
 * Dynamic display soft keyboard
 *
 * @param view view
 */
public static void showSoftInput(Context context, final View view) {
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.requestFocus();
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm == null)
        return;
    imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
}
 
開發者ID:goutham106,項目名稱:GmArchMvvm,代碼行數:15,代碼來源:KeyboardUtils.java

示例4: setViewFocus

import android.view.View; //導入方法依賴的package包/類
public void setViewFocus(View view) {
    if (view != null) {
        view.setFocusable(true);
        view.setFocusableInTouchMode(true);
        view.requestFocus();
        view.requestFocusFromTouch();
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:9,代碼來源:BasicActivity.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:coding-dream,項目名稱:TPlayer,代碼行數:15,代碼來源:TDevice.java

示例6: setEditFocusable

import android.view.View; //導入方法依賴的package包/類
/**
 * 彈出輸入法
 *
 * @param context context
 * @param view    編輯控件
 */
public static void setEditFocusable(final Context context, final View view) {
    view.setFocusableInTouchMode(true);
    view.requestFocus();
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.showSoftInput(view, 0);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:SoftInputUtils.java

示例7: showSoftInput

import android.view.View; //導入方法依賴的package包/類
/**
 * 動態顯示軟鍵盤
 *
 * @param view 視圖
 */
public static void showSoftInput(final View view) {
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.requestFocus();
    InputMethodManager imm = (InputMethodManager) Utils.getApp().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm == null) return;
    imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:KeyboardUtils.java

示例8: openKeyboard

import android.view.View; //導入方法依賴的package包/類
@Override
public void openKeyboard(View view) {
    if(mInputManager != null) {
        view.setFocusableInTouchMode(true);
        view.requestFocus();
        mInputManager.showSoftInput(view, InputMethodManager.SHOW_FORCED);
    }
}
 
開發者ID:nickyangjun,項目名稱:EasyEmoji,代碼行數:9,代碼來源:KeyboardManagerImpl.java

示例9: onBackPressed

import android.view.View; //導入方法依賴的package包/類
private void onBackPressed(View view) {
    view.setFocusableInTouchMode(true);
    view.setOnKeyListener((v, keyCode, event) -> {
        if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
            new AlertDialog.Builder(getActivity())
                    .setTitle("Leave")
                    .setMessage("Exit the watch screen?")
                    .setPositiveButton("Yes", (dialog, id) -> getActivity().finish())
                    .setNegativeButton("No", null)
                    .show();
            return true;
        }
        return false;
    });
}
 
開發者ID:SlotNSlot,項目名稱:SlotNSlot_Android,代碼行數:16,代碼來源:SlotBankerFragment.java

示例10: requestChildFocus

import android.view.View; //導入方法依賴的package包/類
@Override
public void requestChildFocus(View child, View focused) {
    super.requestChildFocus(child, focused);
    dispatchChildFocus(mChildrenFocused && focused != null);
    if (focused != null) {
        focused.setFocusableInTouchMode(false);
    }
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:9,代碼來源:LauncherAppWidgetHostView.java

示例11: showSoftInput

import android.view.View; //導入方法依賴的package包/類
/**
 * 動態顯示軟鍵盤
 *
 * @param view 視圖
 */
public static void showSoftInput(Context context, final View view) {
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.requestFocus();
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm == null) {
        return;
    }
    imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
}
 
開發者ID:xiaobailong24,項目名稱:MVVMArms,代碼行數:16,代碼來源:KeyboardUtils.java

示例12: showInputKeyboard

import android.view.View; //導入方法依賴的package包/類
/**
 * 彈出鍵盤
 *
 * @param et
 */
public static void showInputKeyboard(View et) {
    et.setFocusable(true);
    et.setFocusableInTouchMode(true);
    et.requestFocus();
    InputMethodManager imm = (InputMethodManager) AppUtil.getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(et, 0);
}
 
開發者ID:quickhybrid,項目名稱:quickhybrid-android,代碼行數:13,代碼來源:DeviceUtil.java

示例13: obtainFocus

import android.view.View; //導入方法依賴的package包/類
/**
 * request focus for target view
 * @param v the target view.
 */
public static void obtainFocus(View v) {
    if (v != null) {
        v.setFocusable(true);
        v.setFocusableInTouchMode(true);
        v.requestFocus();
        v.requestFocusFromTouch();
    }
}
 
開發者ID:LightSun,項目名稱:android-util2,代碼行數:13,代碼來源:ViewUtil.java

示例14: showSoftInput

import android.view.View; //導入方法依賴的package包/類
/**
 * 動態顯示軟鍵盤
 * {@link InputMethodManager#showSoftInput(View, int)}
 *
 * @param view 視圖
 */
public static void showSoftInput(@NonNull View view) {
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.requestFocus();
    getInputMethodManager().showSoftInput(view, InputMethodManager.SHOW_FORCED);
}
 
開發者ID:fendoudebb,項目名稱:PlayAndroid,代碼行數:13,代碼來源:KeyBoardUtil.java

示例15: showSoftInput

import android.view.View; //導入方法依賴的package包/類
/**
 * 動態顯示軟鍵盤
 *
 * @param context 上下文
 * @param view 視圖
 */
public static void showSoftInput(Context context, final View view) {
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.requestFocus();
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm == null) return;
    imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
}
 
開發者ID:senierr,項目名稱:ModuleFrame,代碼行數:15,代碼來源:KeyboardUtil.java


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