本文整理匯總了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);
}
示例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;
}
示例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);
}
示例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();
}
}
示例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: 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);
}
示例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);
}
示例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);
}
}
示例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;
});
}
示例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);
}
}
示例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);
}
示例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);
}
示例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();
}
}
示例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);
}
示例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);
}