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

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

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

ImageButton.setClickable介绍

暂无

代码示例

代码示例来源:origin: TeamNewPipe/NewPipe

private void onStateChanged(final int state) {
  switch (state) {
    case BasePlayer.STATE_PAUSED:
      playPauseButton.setImageResource(R.drawable.ic_play_arrow_white);
      break;
    case BasePlayer.STATE_PLAYING:
      playPauseButton.setImageResource(R.drawable.ic_pause_white);
      break;
    case BasePlayer.STATE_COMPLETED:
      playPauseButton.setImageResource(R.drawable.ic_replay_white);
      break;
    default:
      break;
  }
  switch (state) {
    case BasePlayer.STATE_PAUSED:
    case BasePlayer.STATE_PLAYING:
    case BasePlayer.STATE_COMPLETED:
      playPauseButton.setClickable(true);
      playPauseButton.setVisibility(View.VISIBLE);
      progressBar.setVisibility(View.GONE);
      break;
    default:
      playPauseButton.setClickable(false);
      playPauseButton.setVisibility(View.INVISIBLE);
      progressBar.setVisibility(View.VISIBLE);
      break;
  }
}

代码示例来源:origin: CooLoongWu/CoolChat

@Override
  public void afterTextChanged(Editable editable) {
    if (sequence.length() > 0) {
      imgbtn_send.setImageResource(R.mipmap.conversation_btn_messages_send);
      imgbtn_send.setClickable(true);
    } else {
      imgbtn_send.setImageResource(R.mipmap.conversation_btn_messages_send_disable);
      imgbtn_send.setClickable(false);
    }
  }
};

代码示例来源:origin: captain-miao/RecyclerViewUtils

public SimpleParentViewHolder(View itemView) {
  super(itemView);
  mTvTitle = (TextView) itemView.findViewById(R.id.parent_list_item_title_text_view);
  mParentDropDownArrow = (ImageButton) itemView.findViewById(R.id.parent_list_item_expand_arrow);
  mParentDropDownArrow.setClickable(false);
}

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

@Override
public void onWZCameraPreviewStopped(int cameraId) {
  mBtnScreenshot.setEnabled(false);
  mBtnScreenshot.setClickable(false);
}

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

@Override
public void onWZCameraPreviewStarted(WOWZCamera camera, WOWZSize frameSize, int frameRate) {
  mBtnScreenshot.setEnabled(true);
  mBtnScreenshot.setClickable(true);
}

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

public void onTakeScreenshot(View v) {
  // Setting mGrabFrame to true will trigger the video frame listener to become active
  if (!mGrabFrame.get() && !mSavingFrame.get()) {
    mBtnScreenshot.setEnabled(false);
    mBtnScreenshot.setClickable(false);
    mGrabFrame.set(true);
  }
}

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

LinearLayout lyt = (LinearLayout)findViewById(R.id.mylayout);

LinearLayout buttonsLinearLayout = new LinearLayout(context);
buttonsLinearLayout.setOrientation(LinearLayout.HORIZONTAL);

for(i=0;i<=3 ;i++)
{
  ImageButton ib= new ImageButton(this);
  BitmapDrawable imagebd;
  ib.setClickable(true);
  imageid = getResources().getIdentifier("drawable/" + image,null,getPackageName());

  ib.setBackgroundResource(imageid);

  buttonsLinearLayout.addView(ib);
}
lyt.addView(buttonsLinearLayout);

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

LinearLayout lyt = (LinearLayout) findViewById(R.id.mylayout);
lyt.setOrientation(LinearLayout.HORIZONTAL);
for(i=0;i<=3 ;i++) {
  ImageButton ib= new ImageButton(this);
  BitmapDrawable imagebd;
  ib.setClickable(true);
  imageid = getResources().getIdentifier("drawable/" + image,null,getPackageName());

  ib.setBackgroundResource(imageid);

  lyt.addView(ib);
}

代码示例来源:origin: geniusgithub/AndroidDialer

public void hideArchiveButton() {
  mArchiveSpace.setVisibility(View.GONE);
  mArchiveButton.setVisibility(View.GONE);
  mArchiveButton.setClickable(false);
  mArchiveButton.setEnabled(false);
}

代码示例来源: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: WowzaMediaSystems/gocoder-sdk-samples-android

@Override
  public void onWZCameraPreviewError(WOWZCamera camera, WOWZError error) {
    mBtnScreenshot.setEnabled(false);
    mBtnScreenshot.setClickable(false);
    displayErrorDialog(error);
  }
});

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

public void setEnabled(boolean enabled) {
  imageButton.setClickable(enabled);
  imageButton.setImageAlpha(isEnabled() ? 255 : 125);
}

代码示例来源:origin: woefe/ShoppingList

private void setButtonEnabled(ImageButton button, boolean enabled) {
  button.setEnabled(enabled);
  button.setClickable(enabled);
  button.setImageAlpha(enabled ? 255 : 100);
}

代码示例来源:origin: geniusgithub/AndroidDialer

@Override
  public void onPostExecute(Boolean archived) {
    if (!Objects.equals(voicemailUri, mVoicemailUri)) {
      return;
    }
    if (archived) {
      hideArchiveButton();
    } else {
      mArchiveSpace.setVisibility(View.VISIBLE);
      mArchiveButton.setVisibility(View.VISIBLE);
      mArchiveButton.setClickable(true);
      mArchiveButton.setEnabled(true);
    }
  }
});

代码示例来源:origin: icechen1/Notable

public void afterTextChanged(Editable s) {
  if(editText.length() > 0){
    addBtn.setImageDrawable(getResources().getDrawable(sendResourceId));
    addBtn.setEnabled(true);
    addBtn.setClickable(true);
    voiceBtn.setVisibility(View.GONE);
  }else{
    addBtn.setImageDrawable(getResources().getDrawable(disabledResourceId));                   
    addBtn.setEnabled(false);
    addBtn.setClickable(false);
    voiceBtn.setVisibility(View.VISIBLE);
  }
}
public void beforeTextChanged(CharSequence s, int start, int count, int after){}

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

public View getView(int position, View convertView, ViewGroup parent) {
   if (convertView == null) { // if it's not recycled, initialize some
                 // attributes
     LayoutInflater li = (LayoutInflater) mContext
         .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     convertView = li.inflate(R.layout.icon_launcher, null);
   } 
   TextView tv = (TextView) convertView.findViewById(R.id.icon_text);
   ImageButton ib = (ImageButton) convertView.findViewById(R.id.icon_image);
   LinearLayout icon = (LinearLayout) convertView
           .findViewById(R.id.icon_launcher);
   // icon.setLayoutParams(new GridView.LayoutParams(203,200));
   ib.setScaleType(ib.getScaleType().FIT_XY);
   ib.setPadding(1, 1, 1, 1);
   ib.setFocusable(false);
   ib.setClickable(false);
   ib.setImageBitmap(BitmapFactory.decodeFile(mThumbIds.get(position)));
       tv.setText(mTextsIds.get(position));
   return convertView;
 }

代码示例来源:origin: pmarks-net/chromadoze

public void setFragmentId(int id) {
  mFragmentId = id;
  final boolean enableUp = id != FragmentIndex.ID_CHROMA_DOZE;
  ActionBar actionBar = getSupportActionBar();
  supportInvalidateOptionsMenu();
  // Use the default left arrow, or a scaled-down Chroma Doze icon.
  actionBar.setHomeAsUpIndicator(enableUp ? null : mToolbarIcon);
  // When we're on the main page, make the icon non-clickable.
  ImageButton navUp = findImageButton(findViewById(R.id.toolbar));
  if (navUp != null) {
    navUp.setClickable(enableUp);
  }
  mNavSpinner.setSelection(id);
}

代码示例来源:origin: avluis/Hentoid

/**
 * Create the button for the given attribute type
 *
 * @param attr Attribute Type the button should represent
 * @return Button representing the given Attribute type
 */
private ImageButton createAttributeSectionButton(AttributeType attr)
{
  ImageButton button = new ImageButton(mContext);
  button.setBackgroundResource(R.drawable.btn_attribute_section_off);
  button.setImageResource(attr.getIcon());
  button.setClickable(true);
  button.setFocusable(true);
  button.setOnClickListener(v -> selectAttrButton(button));
  button.setTag(attr);
  return button;
}

代码示例来源: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: Calsign/APDE

public void correctUndoRedoEnabled() {
  boolean settingsEnabled = getGlobalState().getPref("pref_key_undo_redo", true);
  
  // Hide undo/redo if user has disabled undo/redo or if we're in an example
  findViewById(R.id.undo_redo_container).setVisibility(settingsEnabled && !getGlobalState().isExample() ? View.VISIBLE : View.GONE);
  
  SketchFile sketchFile = getSelectedSketchFile();
  boolean canUndo = sketchFile != null && sketchFile.canUndo();
  boolean canRedo = sketchFile != null && sketchFile.canRedo();
  
  undoButton.setEnabled(canUndo);
  redoButton.setEnabled(canRedo);
  undoButton.setClickable(canUndo);
  redoButton.setClickable(canRedo);
  
  int alphaEnabled = getResources().getInteger(R.integer.prop_menu_comp_select_alpha_selected);
  int alphaDisabled = getResources().getInteger(R.integer.prop_menu_comp_select_alpha_unselected);
  
  undoButton.setImageAlpha(canUndo ? alphaEnabled : alphaDisabled);
  redoButton.setImageAlpha(canRedo ? alphaEnabled : alphaDisabled);
}

相关文章

ImageButton类方法