当前位置: 首页>>代码示例>>Java>>正文


Java View.requestFocusFromTouch方法代码示例

本文整理汇总了Java中android.view.View.requestFocusFromTouch方法的典型用法代码示例。如果您正苦于以下问题:Java View.requestFocusFromTouch方法的具体用法?Java View.requestFocusFromTouch怎么用?Java View.requestFocusFromTouch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.requestFocusFromTouch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clearInputMethodManagerLeak

import android.view.View; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
private void clearInputMethodManagerLeak() {
    try {
        Object lock = mHField.get(inputMethodManager);
        // This is highly dependent on the InputMethodManager implementation.
        synchronized (lock) {
            View servedView = (View) mServedViewField.get(inputMethodManager);
            if (servedView != null) {

                boolean servedViewAttached = servedView.getWindowVisibility() != View.GONE;

                if (servedViewAttached) {
                    // The view held by the IMM was replaced without a global focus change. Let's make
                    // sure we get notified when that view detaches.

                    // Avoid double registration.
                    servedView.removeOnAttachStateChangeListener(this);
                    servedView.addOnAttachStateChangeListener(this);
                } else {
                    // servedView is not attached. InputMethodManager is being stupid!
                    Activity activity = extractActivity(servedView.getContext());
                    if (activity == null || activity.getWindow() == null) {
                        // Unlikely case. Let's finish the input anyways.
                        finishInputLockedMethod.invoke(inputMethodManager);
                    } else {
                        View decorView = activity.getWindow().peekDecorView();
                        boolean windowAttached = decorView.getWindowVisibility() != View.GONE;
                        if (!windowAttached) {
                            finishInputLockedMethod.invoke(inputMethodManager);
                        } else {
                            decorView.requestFocusFromTouch();
                        }
                    }
                }
            }
        }
    } catch (IllegalAccessException | InvocationTargetException unexpected) {
        Log.e("IMMLeaks", "Unexpected reflection exception", unexpected);
    }
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:41,代码来源:IMMLeaks.java

示例2: 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

示例3: onClick

import android.view.View; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
	switch (v.getId()) {
	case R.id.bu_setTime:
		v.requestFocus();
		v.requestFocusFromTouch();
		setPushTime();
		break;
	}
}
 
开发者ID:LuoLuo0101,项目名称:JPush,代码行数:11,代码来源:SettingActivity.java

示例4: clearInputMethodManagerLeak

import android.view.View; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private void clearInputMethodManagerLeak() {
  try {
    Object lock = mHField.get(inputMethodManager);
    // This is highly dependent on the InputMethodManager implementation.
    synchronized (lock) {
      View servedView = (View) mServedViewField.get(inputMethodManager);
      if (servedView != null) {

        boolean servedViewAttached = servedView.getWindowVisibility() != View.GONE;

        if (servedViewAttached) {
          // The view held by the IMM was replaced without a global focus change. Let's make
          // sure we get notified when that view detaches.

          // Avoid double registration.
          servedView.removeOnAttachStateChangeListener(this);
          servedView.addOnAttachStateChangeListener(this);
        } else {
          // servedView is not attached. InputMethodManager is being stupid!
          Activity activity = extractActivity(servedView.getContext());
          if (activity == null || activity.getWindow() == null) {
            // Unlikely case. Let's finish the input anyways.
            finishInputLockedMethod.invoke(inputMethodManager);
          } else {
            View decorView = activity.getWindow().peekDecorView();
            boolean windowAttached = decorView.getWindowVisibility() != View.GONE;
            if (!windowAttached) {
              finishInputLockedMethod.invoke(inputMethodManager);
            } else {
              decorView.requestFocusFromTouch();
            }
          }
        }
      }
    }
  } catch (IllegalAccessException | InvocationTargetException unexpected) {
    Log.e("IMMLeaks", "Unexpected reflection exception", unexpected);
  }
}
 
开发者ID:GcsSloop,项目名称:diycode,代码行数:41,代码来源:IMMLeaks.java

示例5: 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

示例6: focus

import android.view.View; //导入方法依赖的package包/类
public static void focus(View v) {
    v.setFocusable(true);
    v.setFocusableInTouchMode(true);
    v.requestFocus();
    v.requestFocusFromTouch();
}
 
开发者ID:MedicationReminder,项目名称:MedicationReminder,代码行数:7,代码来源:PlaceHolderFragment.java


注:本文中的android.view.View.requestFocusFromTouch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。