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


Java View.setOnTouchListener方法代码示例

本文整理汇总了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);
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:23,代码来源:CardStackAdapter.java

示例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);
        }
    }
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:31,代码来源:BaseItemDraggableAdapter.java

示例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);
        }
    });
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:19,代码来源:PagerSlidingTabStrip.java

示例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);
        }
    });
}
 
开发者ID:DSM-DMS,项目名称:DMS,代码行数:17,代码来源:FacilityReportAdapter.java

示例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());
}
 
开发者ID:eventtus,项目名称:photo-editor-android,代码行数:20,代码来源:PhotoEditorSDK.java

示例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);
        }
    }
}
 
开发者ID:ArnauBlanch,项目名称:civify-app,代码行数:19,代码来源:CreateIssueActivity.java

示例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);
    }
  }
}
 
开发者ID:goutfeb,项目名称:ElephantAsia,代码行数:27,代码来源:KeyboardHelpers.java

示例8: setOnTouchListener

import android.view.View; //导入方法依赖的package包/类
public ViewHolderHelper setOnTouchListener(int viewId,
                                           View.OnTouchListener listener) {
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:7,代码来源:ViewHolderHelper.java

示例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;
}
 
开发者ID:aumarbello,项目名称:Tasks,代码行数:15,代码来源:TaskViewHolder.java

示例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;
}
 
开发者ID:youth5201314,项目名称:XFrame,代码行数:7,代码来源:XViewHolder.java

示例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);
        }
    });
}
 
开发者ID:Codigami,项目名称:CFAlertDialog,代码行数:9,代码来源:ViewUtil.java

示例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);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:11,代码来源:MicrophoneRecorderView.java

示例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));
  }
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:9,代码来源:WXComponent.java

示例14: setOnTouchListener

import android.view.View; //导入方法依赖的package包/类
public RvHolder setOnTouchListener(int viewId,
                                     View.OnTouchListener listener) {
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:7,代码来源:RvHolder.java

示例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;
}
 
开发者ID:vsona,项目名称:RxJava2RetrofitDemo,代码行数:7,代码来源:MartianViewHolder.java


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