本文整理汇总了Java中android.view.View.setOnTouchListener方法的典型用法代码示例。如果您正苦于以下问题:Java View.setOnTouchListener方法的具体用法?Java View.setOnTouchListener怎么用?Java View.setOnTouchListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.setOnTouchListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addView
import android.view.View; //导入方法依赖的package包/类
void addView(final int position) {
View root = createView(position, mParent);
root.setOnTouchListener(this);
root.setTag(R.id.cardstack_internal_position_tag, position);
root.setLayerType(View.LAYER_TYPE_HARDWARE, null);
mCardPaddingInternal = root.getPaddingTop();
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, fullCardHeight);
root.setLayoutParams(lp);
if (mShowInitAnimation) {
root.setY(getCardFinalY(position));
setScreenTouchable(false);
} else {
root.setY(getCardOriginalY(position) - mParentPaddingTop);
setScreenTouchable(true);
}
mCardViews[position] = root;
mParent.addView(root);
}
示例2: onBindViewHolder
import android.view.View; //导入方法依赖的package包/类
/**
* To bind different types of holder and solve different the bind events
*
* @param holder
* @param positions
* @see #getDefItemViewType(int)
*/
@Override
public void onBindViewHolder(K holder, int positions) {
super.onBindViewHolder(holder, positions);
int viewType = holder.getItemViewType();
if (mItemTouchHelper != null && itemDragEnabled && viewType != LOADING_VIEW && viewType != HEADER_VIEW
&& viewType != EMPTY_VIEW && viewType != FOOTER_VIEW) {
if (mToggleViewId != NO_TOGGLE_VIEW) {
View toggleView = ((BaseViewHolder) holder).getView(mToggleViewId);
if (toggleView != null) {
toggleView.setTag(R.id.BaseQuickAdapter_viewholder_support, holder);
if (mDragOnLongPress) {
toggleView.setOnLongClickListener(mOnToggleViewLongClickListener);
} else {
toggleView.setOnTouchListener(mOnToggleViewTouchListener);
}
}
} else {
holder.itemView.setTag(R.id.BaseQuickAdapter_viewholder_support, holder);
holder.itemView.setOnLongClickListener(mOnToggleViewLongClickListener);
}
}
}
示例3: addTabDoubleTapListener
import android.view.View; //导入方法依赖的package包/类
private void addTabDoubleTapListener(final int position, View tab) {
final GestureDetector gd = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDoubleTap(MotionEvent e) {
if (onTabDoubleTapListener != null)
onTabDoubleTapListener.onCurrentTabDoubleTap(position);
return true;
}
});
tab.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return gd.onTouchEvent(event);
}
});
}
示例4: ItemViewHolder
import android.view.View; //导入方法依赖的package包/类
public ItemViewHolder(View itemView) {
super(itemView);
mTitleTV = (TextView) itemView.findViewById(R.id.tv_facilityreport_title);
mWriterTV = (TextView) itemView.findViewById(R.id.tv_facilityreport_writer);
mWriteDateTV = (TextView) itemView.findViewById(R.id.tv_facilityreport_writedate);
itemView.setOnTouchListener(Listeners.changeTextColorOnTouchListener(mContext, mTitleTV));
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FacilityReport facilityReport = mFacilityReportList.get(getAdapterPosition());
viewArticle(facilityReport);
}
});
}
示例5: addImage
import android.view.View; //导入方法依赖的package包/类
public void addImage(Bitmap desiredImage) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View imageRootView = inflater.inflate(R.layout.photo_editor_sdk_image_item_list, null);
ImageView imageView = (ImageView) imageRootView.findViewById(R.id.photo_editor_sdk_image_iv);
imageView.setImageBitmap(desiredImage);
imageView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT));
MultiTouchListener multiTouchListener = new MultiTouchListener(deleteView,
parentView, this.imageView, onPhotoEditorSDKListener);
multiTouchListener.setOnMultiTouchListener(this);
imageRootView.setOnTouchListener(multiTouchListener);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
parentView.addView(imageRootView, params);
addedViews.add(imageRootView);
if (onPhotoEditorSDKListener != null)
onPhotoEditorSDKListener.onAddViewListener(ViewType.IMAGE, addedViews.size());
}
示例6: setupCloseKeyboard
import android.view.View; //导入方法依赖的package包/类
private void setupCloseKeyboard(final View view) {
if (!(view instanceof EditText)) {
view.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
hideSoftKeyboard();
view.requestFocus();
return false;
}
});
}
if (view instanceof ViewGroup) {
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
View innerView = ((ViewGroup) view).getChildAt(i);
setupCloseKeyboard(innerView);
}
}
}
示例7: hideKeyboardListener
import android.view.View; //导入方法依赖的package包/类
/**
* Attach a listener that hide keyboard to all View and nested View except EditText
* It allows the soft keyboard to get hidden automatically when EditText is not focus
*
* @param view Current view
* @param activity Current activity
*/
public static void hideKeyboardListener(View view, final Activity activity) {
// Set up touch listener for non-text box views to hide keyboard.
if (!(view instanceof EditText)) {
view.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
hideSoftKeyboard(activity);
return false;
}
});
}
//If a layout container, iterate over children and seed recursion.
if (view instanceof ViewGroup) {
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
View innerView = ((ViewGroup) view).getChildAt(i);
hideKeyboardListener(innerView, activity);
}
}
}
示例8: setOnTouchListener
import android.view.View; //导入方法依赖的package包/类
public ViewHolderHelper setOnTouchListener(int viewId,
View.OnTouchListener listener) {
View view = getView(viewId);
view.setOnTouchListener(listener);
return this;
}
示例9: TaskViewHolder
import android.view.View; //导入方法依赖的package包/类
public TaskViewHolder(View itemView, ItemActions actions,
Context context, List<Task> taskList, TaskPref pref) {
super(itemView);
taskTitle = itemView.findViewById(R.id.task_title);
taskDate = itemView.findViewById(R.id.task_time);
isDone = itemView.findViewById(R.id.task_done);
itemView.setOnTouchListener(new SwipeTouchListener(context, this));
this.actions = actions;
this.context = context;
this.taskList = taskList;
this.pref = pref;
}
示例10: setOnTouchListener
import android.view.View; //导入方法依赖的package包/类
public XViewHolder setOnTouchListener(@IdRes int viewId,
View.OnTouchListener listener) {
View view = getView(viewId);
view.setOnTouchListener(listener);
return this;
}
示例11: addBounceEffect
import android.view.View; //导入方法依赖的package包/类
public static void addBounceEffect(View view) {
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return onButtonTouch(v, event);
}
});
}
示例12: onFinishInflate
import android.view.View; //导入方法依赖的package包/类
@Override
public void onFinishInflate() {
super.onFinishInflate();
ImageView recordButtonFab = ViewUtil.findById(this, R.id.quick_audio_fab);
this.floatingRecordButton = new FloatingRecordButton(getContext(), recordButtonFab);
View recordButton = ViewUtil.findById(this, R.id.quick_audio_toggle);
recordButton.setOnTouchListener(this);
}
示例13: setActiveTouchListener
import android.view.View; //导入方法依赖的package包/类
private void setActiveTouchListener(){
boolean hasActivePesudo = mDomObj.getStyles().getPesudoStyles().containsKey(Constants.PESUDO.ACTIVE);
View view;
if(hasActivePesudo && (view = getRealView()) != null) {
boolean hasTouchConsumer = (mHostClickListeners != null && mHostClickListeners.size() > 0) || wxGesture != null;
view.setOnTouchListener(new TouchActivePseudoListener(this,!hasTouchConsumer));
}
}
示例14: setOnTouchListener
import android.view.View; //导入方法依赖的package包/类
public RvHolder setOnTouchListener(int viewId,
View.OnTouchListener listener) {
View view = getView(viewId);
view.setOnTouchListener(listener);
return this;
}
示例15: setOnTouchListener
import android.view.View; //导入方法依赖的package包/类
@Override
public MartianViewHolder setOnTouchListener(int viewId, View.OnTouchListener listener) {
View view = getView(viewId);
view.setOnTouchListener(listener);
return this;
}