android.widget.ImageButton.setOnTouchListener()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(148)

本文整理了Java中android.widget.ImageButton.setOnTouchListener()方法的一些代码示例,展示了ImageButton.setOnTouchListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageButton.setOnTouchListener()方法的具体详情如下:
包路径:android.widget.ImageButton
类名称:ImageButton
方法名:setOnTouchListener

ImageButton.setOnTouchListener介绍

暂无

代码示例

代码示例来源:origin: fossasia/pslab-android

/**
 * Handles action when user releases long click on an increment or a decrement button
 *
 * @param up   increment button
 * @param down decrement button
 */
@SuppressLint("ClickableViewAccessibility")
private void monitorLongClicks(ImageButton up, ImageButton down) {
  up.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {
      view.onTouchEvent(motionEvent);
      if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
        stopCounter();
      }
      return true;
    }
  });
  down.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {
      view.onTouchEvent(motionEvent);
      if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
        stopCounter();
      }
      return true;
    }
  });
}

代码示例来源:origin: tony-Shx/Swface

private void initOnClick() {
  imageButton_login.setOnTouchListener(this);
  imageButton_login.setOnClickListener(this);
}

代码示例来源:origin: stackoverflow.com

power.setOnTouchListener(this);

代码示例来源:origin: WowzaMediaSystems/gocoder-sdk-samples-android

public ControlButton(Activity activity, int resourceId, final boolean enabled) {
  this.pressedColor = activity.getResources().getColor(R.color.controlButtonPressed);
  this.imageButton = (ImageButton) activity.findViewById(resourceId);
  this.imageButton.setClickable(enabled);
  this.imageButton.setOnTouchListener(new View.OnTouchListener() {
    public boolean onTouch(View v, MotionEvent event) {
      if (!imageButton.isClickable()) return false;
      ImageButton btn = (ImageButton) v;
      if (event.getAction() == MotionEvent.ACTION_DOWN) {
        btn.getDrawable().setColorFilter(pressedColor, PorterDuff.Mode.SRC_IN);
      } else if (event.getAction() == MotionEvent.ACTION_UP) {
        btn.getDrawable().clearColorFilter();
      }
      return false;
    }
  });
  setEnabled(enabled);
}

代码示例来源:origin: stackoverflow.com

final ImageButton resetButton = (ImageButton) findViewById(R.id.button_ResetData);
     final TextView resetButton_Title = (TextView) findViewById(R.id.textview_button_ResetData_title);
     View.OnTouchListener onTouchListener_ResetButton = new View.OnTouchListener() {
       @Override
       public boolean onTouch(View view, MotionEvent motionEvent) {
         switch (motionEvent.getAction()){
           case MotionEvent.ACTION_DOWN:
             resetButton.setImageResource(R.drawable.trash_pressed);
             resetButton_Title.setTextColor(getResources().getColor(R.color.Blue_Light));
             break;
           case MotionEvent.ACTION_UP:
             resetButton.setImageResource(R.drawable.trash);
             resetButton_Title.setTextColor(Color.WHITE);
             AlertDialog.Builder builder = new Builder(MainActivity.this);
             builder.setMessage("Are you sure you want to clear the list (except \"In progress\")?")
                 .setPositiveButton("Yes", resetListDialogClickListener)
                 .setNegativeButton("No", resetListDialogClickListener);
             AlertDialog dialog = builder.show();
             TextView messageView = (TextView) dialog.findViewById(android.R.id.message);
             messageView.setGravity(Gravity.CENTER);
         }
         return false;
       }
     };
     resetButton.setOnTouchListener(onTouchListener_ResetButton);
     resetButton_Title.setOnTouchListener(onTouchListener_ResetButton);

代码示例来源:origin: BrightcoveOS/android-player-samples

holder.downloadButton.setOnTouchListener(new View.OnTouchListener() {
  @Override
  public boolean onTouch(View v, MotionEvent event) {
holder.pauseButton.setOnTouchListener(new View.OnTouchListener() {
  @Override
  public boolean onTouch(View v, MotionEvent event) {
holder.resumeButton.setOnTouchListener(new View.OnTouchListener() {
  @Override
  public boolean onTouch(View v, MotionEvent event) {
holder.deleteButton.setOnTouchListener(new View.OnTouchListener() {
  @Override
  public boolean onTouch(View v, MotionEvent event) {

代码示例来源:origin: klinker24/Android-Blur-Launcher

none.setOnTouchListener(mHapticFeedbackTouchListener);
none.setOnClickListener(new View.OnClickListener() {
  @Override
addNew.setOnTouchListener(mHapticFeedbackTouchListener);
addNew.setOnClickListener(new View.OnClickListener() {
  @Override

代码示例来源:origin: gildaswise/HorizontalCounter

private void setupMinusButton() {
  setMinusButtonColor(minusButtonColor);
  minusButton.setImageDrawable(minusIcon);
  minusButton.setOnTouchListener(getMinusButtonListener());
}

代码示例来源:origin: gildaswise/HorizontalCounter

private void setupPlusButton() {
  setPlusButtonColor(plusButtonColor);
  plusButton.setImageDrawable(plusIcon);
  plusButton.setOnTouchListener(getPlusButtonListener());
}

代码示例来源:origin: derry/delion

/**
 * Creates an on touch listener for the menu button using the given menu handler.
 * @param menuHandler The menu handler to be used for showing the pop up menu.
 */
public void setMenuOnTouchListener(final AppMenuHandler menuHandler) {
  final ImageButton menuBtn = (ImageButton) findViewById(R.id.empty_menu_button);
  final AppMenuButtonHelper menuPopupButtonHelper = new AppMenuButtonHelper(menuHandler);
  menuBtn.setOnTouchListener(menuPopupButtonHelper);
  menuPopupButtonHelper.setOnAppMenuShownListener(new Runnable() {
    @Override
    public void run() {
      RecordUserAction.record("MobileToolbarShowMenu");
    }
  });
}

代码示例来源:origin: adafruit/Bluefruit_LE_Connect_Android

upArrowImageButton.setOnTouchListener(mPadButtonTouchListener);
ImageButton leftArrowImageButton = (ImageButton) findViewById(R.id.leftArrowImageButton);
leftArrowImageButton.setOnTouchListener(mPadButtonTouchListener);
ImageButton rightArrowImageButton = (ImageButton) findViewById(R.id.rightArrowImageButton);
rightArrowImageButton.setOnTouchListener(mPadButtonTouchListener);
ImageButton bottomArrowImageButton = (ImageButton) findViewById(R.id.bottomArrowImageButton);
bottomArrowImageButton.setOnTouchListener(mPadButtonTouchListener);
button1ImageButton.setOnTouchListener(mPadButtonTouchListener);
ImageButton button2ImageButton = (ImageButton) findViewById(R.id.button2ImageButton);
button2ImageButton.setOnTouchListener(mPadButtonTouchListener);
ImageButton button3ImageButton = (ImageButton) findViewById(R.id.button3ImageButton);
button3ImageButton.setOnTouchListener(mPadButtonTouchListener);
ImageButton button4ImageButton = (ImageButton) findViewById(R.id.button4ImageButton);
button4ImageButton.setOnTouchListener(mPadButtonTouchListener);

代码示例来源:origin: fython/BreadcrumbsView

@Override
public void setItem(@NonNull IBreadcrumbItem item) {
  super.setItem(item);
  imageButton.setClickable(item.hasMoreSelect());
  if (item.hasMoreSelect()) {
    List<Map<String, String>> list = new ArrayList<>();
    for (Object obj : item.getItems()) {
      Map<String, String> map = new HashMap<>();
      map.put("text", obj.toString());
      list.add(map);
    }
    ListAdapter adapter = new SimpleAdapter(getPopupThemedContext(), list, R.layout.breadcrumbs_view_dropdown_item, new String[] {"text"}, new int[] {android.R.id.text1});
    popupWindow.setAdapter(adapter);
    popupWindow.setWidth(ViewUtils.measureContentWidth(getPopupThemedContext(), adapter));
    imageButton.setOnTouchListener(popupWindow.createDragToOpenListener(imageButton));
  } else {
    imageButton.setOnTouchListener(null);
  }
}

代码示例来源:origin: stackoverflow.com

button.setOnTouchListener(onTouchCell);

代码示例来源:origin: NASAWorldWind/WorldWindAndroid

private void performLayout() {
  releaseWorldWindows();
  // Get the standard/common layout used for a single globe activity
  // and replace it's contents with a multi-globe layout.
  RelativeLayout layout = (RelativeLayout) findViewById(R.id.globe_content);
  layout.removeAllViews();
  // Add the landscape or portrait layout
  View multiGlobeLayout = getLayoutInflater().inflate(R.layout.multi_globe_content, null);
  layout.addView(multiGlobeLayout);
  // Add a WorldWindow to each of the FrameLayouts in the multi-globe layout.
  FrameLayout globe1 = (FrameLayout) findViewById(R.id.globe_one);
  FrameLayout globe2 = (FrameLayout) findViewById(R.id.globe_two);
  ImageButton splitter = (ImageButton) findViewById(R.id.splitter);
  globe1.addView(getWorldWindow(0) == null ? createWorldWindow() : getWorldWindow(0), new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
  globe2.addView(getWorldWindow(1) == null ? createWorldWindow() : getWorldWindow(1), new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
  splitter.setOnTouchListener(new SplitterTouchListener(globe1, globe2, splitter));
}

代码示例来源:origin: techstar-cloud/memorize-en

floatingButton.setOnTouchListener(new View.OnTouchListener() {
  private int initialX;
  private int initialY;

代码示例来源:origin: LightingContour/Toucher

imageButton1.setOnTouchListener(new View.OnTouchListener() {
  @Override
  public boolean onTouch(View v, MotionEvent event) {

代码示例来源:origin: lime-ime/limeime

public void initViews() {
  if (mCandidateView == null) {
    mButtonExpandLayout = findViewById(R.id.candidate_right_parent);
    mButtonExpand = (ImageButton) findViewById(R.id.candidate_right);
    if (mButtonExpand != null) {
      mButtonExpand.setOnTouchListener(this);
    }
    mCandidateView = (CandidateView) findViewById(R.id.candidates);
    TextView mEmbeddedTextView = (TextView) findViewById(R.id.embeddedComposing);
    mCandidateView.setEmbeddedComposingView(mEmbeddedTextView);
    mCandidateView.setBackgroundColor(mCandidateView.mColorBackground);
    mButtonExpand.setBackgroundColor(mCandidateView.mColorBackground);
    mButtonExpand.setImageDrawable(mCandidateView.mDrawableExpandButton);
  }
}

代码示例来源:origin: klinker24/Android-Blur-Launcher

public void setFeedback() {
  View.OnTouchListener mHapticFeedbackTouchListener = new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
      if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
        v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
      }
      return false;
    }
  };
  layout.setOnTouchListener(mHapticFeedbackTouchListener);
  visuals.setOnTouchListener(mHapticFeedbackTouchListener);
  dock.setOnTouchListener(mHapticFeedbackTouchListener);
  chooseFrag.setOnTouchListener(mHapticFeedbackTouchListener);
  help.setOnTouchListener(mHapticFeedbackTouchListener);
  donate.setOnTouchListener(mHapticFeedbackTouchListener);
  klinkerApps.setOnTouchListener(mHapticFeedbackTouchListener);
  restartLauncher.setOnTouchListener(mHapticFeedbackTouchListener);
  overflow.setOnTouchListener(mHapticFeedbackTouchListener);
}

代码示例来源:origin: souch/SMP

playButton.setOnTouchListener(touchListener);
gotoButton.setOnTouchListener(touchListener);
gotoButton.setOnLongClickListener(gotoSongLongListener);
ImageButton prevButton = (ImageButton) findViewById(R.id.prev_button);
prevButton.setOnLongClickListener(prevGroupLongListener);
prevButton.setOnTouchListener(touchListener);
ImageButton nextButton = (ImageButton) findViewById(R.id.next_button);
nextButton.setOnLongClickListener(nextGroupLongListener);
nextButton.setOnTouchListener(touchListener);
albumImage.setOnTouchListener(new OnSwipeTouchListener(getApplicationContext()) {
  public void onSwipeTop() {
    if (detailsBigCoverArt == true) {

代码示例来源:origin: easemob/kefu-android-demo

mRecordBtn.setOnTouchListener(new OnTouchListener() {
  @Override
  public boolean onTouch(View v, MotionEvent event) {

相关文章

ImageButton类方法