本文整理匯總了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);
}
}
示例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();
}
}
示例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;
}
}
示例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);
}
}
示例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();
}
}
示例6: focus
import android.view.View; //導入方法依賴的package包/類
public static void focus(View v) {
v.setFocusable(true);
v.setFocusableInTouchMode(true);
v.requestFocus();
v.requestFocusFromTouch();
}