本文整理汇总了Java中android.support.v4.view.ViewCompat.hasOnClickListeners方法的典型用法代码示例。如果您正苦于以下问题:Java ViewCompat.hasOnClickListeners方法的具体用法?Java ViewCompat.hasOnClickListeners怎么用?Java ViewCompat.hasOnClickListeners使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.ViewCompat
的用法示例。
在下文中一共展示了ViewCompat.hasOnClickListeners方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkOnClickListener
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
* android:onClick doesn't handle views with a ContextWrapper context. This method
* backports new framework functionality to traverse the Context wrappers to find a
* suitable target.
*/
private void checkOnClickListener(View view, AttributeSet attrs) {
final Context context = view.getContext();
if (!(context instanceof ContextWrapper) ||
(Build.VERSION.SDK_INT >= 15 && !ViewCompat.hasOnClickListeners(view))) {
// Skip our compat functionality if: the Context isn't a ContextWrapper, or
// the view doesn't have an OnClickListener (we can only rely on this on API 15+ so
// always use our compat code on older devices)
return;
}
final TypedArray a = context.obtainStyledAttributes(attrs, sOnClickAttrs);
final String handlerName = a.getString(0);
if (handlerName != null) {
view.setOnClickListener(new DeclaredOnClickListener(view, handlerName));
}
a.recycle();
}
示例2: onChildAttachedToWindow
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void onChildAttachedToWindow(View child) {
super.onChildAttachedToWindow(child);
if (!ViewCompat.hasOnClickListeners(child)) {
child.setClickable(true);
child.setOnClickListener(mOnItemOperateListenerInternalInternal);
}
child.setOnLongClickListener(mOnItemOperateListenerInternalInternal);
}
示例3: checkOnClickListener
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
* android:onClick doesn't handle views with a ContextWrapper context. This method
* backports new framework functionality to traverse the Context wrappers to find a
* suitable target.
*/
private void checkOnClickListener(View view, AttributeSet attrs) {
final Context context = view.getContext();
if (!(context instanceof ContextWrapper) ||
(Build.VERSION.SDK_INT >= 15 && !ViewCompat.hasOnClickListeners(view))) {
// Skip our compat functionality if: the Context isn't a ContextWrapper, or
// the view doesn't have an OnClickListener (we can only rely on this on API 15+ so
// always use our compat code on older devices)
return;
}
final TypedArray a = context.obtainStyledAttributes(attrs, sOnClickAttrs);
final String handlerName = a.getString(0);
if (handlerName != null) {
view.setOnClickListener(new SkinAppCompatViewInflater.DeclaredOnClickListener(view, handlerName));
}
a.recycle();
}
示例4: checkOnClickListener
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void checkOnClickListener(View view, AttributeSet attrs) {
Context context = view.getContext();
if (!(context instanceof ContextWrapper)) {
return;
}
if (VERSION.SDK_INT < 15 || ViewCompat.hasOnClickListeners(view)) {
TypedArray a = context.obtainStyledAttributes(attrs, sOnClickAttrs);
String handlerName = a.getString(0);
if (handlerName != null) {
view.setOnClickListener(new DeclaredOnClickListener(view, handlerName));
}
a.recycle();
}
}