android.widget.Button.setSelected()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(197)

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

Button.setSelected介绍

暂无

代码示例

代码示例来源:origin: JavaNoober/BackgroundLibrary

@Override
  public void onClick(View v) {
    if(btnLike2.isSelected()){
      btnLike2.setText("未点赞");
    }else {
      btnLike2.setText("已点赞");
    }
    btnLike2.setSelected(!btnLike2.isSelected());
  }
});

代码示例来源:origin: vilyever/AndroidDrawingView

private void selectButton(List<Button> buttons, Button button) {
    for (Button b : buttons) {
      b.setSelected(b == button);
    }
  }
}

代码示例来源:origin: KosyanMedia/Aviasales-Android-SDK

private void setSelectedButton(boolean morningButtonSelected, boolean dayButtonSelected, boolean eveningButtonSelected) {
  morningButton.setSelected(morningButtonSelected);
  dayButton.setSelected(dayButtonSelected);
  eveningButton.setSelected(eveningButtonSelected);
}

代码示例来源:origin: KosyanMedia/Aviasales-Android-SDK

private void setSelectedButton(boolean morningButtonSelected, boolean dayButtonSelected, boolean eveningButtonSelected) {
  morningButton.setSelected(morningButtonSelected);
  dayButton.setSelected(dayButtonSelected);
  eveningButton.setSelected(eveningButtonSelected);
}

代码示例来源:origin: EvanRespaut/Equate

/**
 * Changes equals button color according the the input boolean value.
 * Equals button is colored normally when button is not selected. When
 * a unit is selected, equals button looks like a regular op button
 */
public void setEqualButtonColor(boolean unHighlighted) {
  mEqualsButton.setSelected(unHighlighted);
}

代码示例来源:origin: KosyanMedia/Aviasales-Android-SDK

public void setDefaultState() {
    morningButton.setSelected(false);
    dayButton.setSelected(false);
    eveningButton.setSelected(false);
  }
}

代码示例来源:origin: KosyanMedia/Aviasales-Android-SDK

public void setDefaultState() {
    morningButton.setSelected(false);
    dayButton.setSelected(false);
    eveningButton.setSelected(false);
  }
}

代码示例来源:origin: VREMSoftwareDevelopment/WiFiAnalyzer

private void setSelected(Button button, boolean selected) {
  if (selected) {
    button.setBackgroundColor(ContextCompat.getColor(context, R.color.connected));
    button.setSelected(true);
  } else {
    button.setBackgroundColor(ContextCompat.getColor(context, R.color.connected_background));
    button.setSelected(false);
  }
}

代码示例来源:origin: nenick/espresso-macchiato

@Override
  public void run() {
    view.setSelected(true);
  }
});

代码示例来源:origin: 1993hzw/Androids

@Override
  public void onKeyboardStateChanged(boolean isActive, int keyboardHeight) {
    if (isActive) { // 输入法打开
      if (mKeyboardHeight != keyboardHeight) { // 键盘发生改变时才设置emojiView的高度,因为会触发onGlobalLayoutChanged,导致onKeyboardStateChanged再次被调用
        mKeyboardHeight = keyboardHeight;
        initEmojiView(); // 每次输入法弹起时,设置emojiView的高度为键盘的高度,以便下次emojiView弹出时刚好等于键盘高度
      }
      if (mEmojiBtn.isSelected()) { // 表情打开状态下
        mEmojiView.setVisibility(View.GONE);
        mEmojiBtn.setSelected(false);
      }
    }
  }
});

代码示例来源:origin: com.albedinsky.android.support/support-dialogs

/**
 * Selects the AM button, if it is not selected yet, and fires {@link OnSelectionChangeListener#onAmPmSelectionChanged(DialogTimeTitleView, boolean)}
 * with {@code true} value.
 *
 * @see #selectPmButton()
 */
public void selectAmButton() {
  if (mButtonPm == null || mButtonAm == null || mButtonAm.isSelected()) {
    return;
  }
  mButtonAm.setSelected(true);
  mButtonPm.setSelected(false);
  if (mListener != null) {
    mListener.onAmPmSelectionChanged(this, true);
  }
}

代码示例来源:origin: com.albedinsky.android.support/support-dialogs

/**
 * Selects the PM button, if it is not selected yet, and fires {@link OnSelectionChangeListener#onAmPmSelectionChanged(DialogTimeTitleView, boolean)}
 * with {@code false} value.
 *
 * @see #selectAmButton()
 */
public void selectPmButton() {
  if (mButtonAm == null || mButtonPm == null || mButtonPm.isSelected()) {
    return;
  }
  mButtonAm.setSelected(false);
  mButtonPm.setSelected(true);
  if (mListener != null) {
    mListener.onAmPmSelectionChanged(this, false);
  }
}

代码示例来源:origin: com.albedinsky.android/dialogs

/**
 * Selects the AM button, if it is not selected yet, and fires {@link OnSelectionChangeListener#onAmPmSelectionChanged(DialogTimeTitleView, boolean)}
 * with {@code true} value.
 *
 * @see #selectPmButton()
 */
public void selectAmButton() {
  if (mButtonPm == null || mButtonAm == null || mButtonAm.isSelected()) {
    return;
  }
  mButtonAm.setSelected(true);
  mButtonPm.setSelected(false);
  if (mListener != null) {
    mListener.onAmPmSelectionChanged(this, true);
  }
}

代码示例来源:origin: com.albedinsky.android/dialogs

/**
 * Selects the PM button, if it is not selected yet, and fires {@link OnSelectionChangeListener#onAmPmSelectionChanged(DialogTimeTitleView, boolean)}
 * with {@code false} value.
 *
 * @see #selectAmButton()
 */
public void selectPmButton() {
  if (mButtonAm == null || mButtonPm == null || mButtonPm.isSelected()) {
    return;
  }
  mButtonAm.setSelected(false);
  mButtonPm.setSelected(true);
  if (mListener != null) {
    mListener.onAmPmSelectionChanged(this, false);
  }
}

代码示例来源:origin: ShawnBaker/RPiCameraViewer

private void loadLogFile(File logFile, int noFileId, Button thisButton, Button otherButton)
{
  // configure the buttons
  Log.info("load log file: " + logFile.getName());
  thisButton.setSelected(true);
  otherButton.setSelected(false);
  // display the loading message
  ArrayList<String> loading = new ArrayList<>();
  loading.add(getString(R.string.loading));
  ArrayAdapter<String> loadingAdapter = new ArrayAdapter<>(this, R.layout.row_log, loading);
  listView.setAdapter(loadingAdapter);
  // load the list asynchronously
  new LogFileLoader(logFile, noFileId).execute();
}

代码示例来源:origin: bodismile/bmob-newim-demo

private void onTabIndex(int index){
  if (currentTabIndex != index) {
    FragmentTransaction trx = getSupportFragmentManager().beginTransaction();
    trx.hide(fragments[currentTabIndex]);
    if (!fragments[index].isAdded()) {
      trx.add(R.id.fragment_container, fragments[index]);
    }
    trx.show(fragments[index]).commit();
  }
  mTabs[currentTabIndex].setSelected(false);
  mTabs[index].setSelected(true);
  currentTabIndex = index;
}

代码示例来源:origin: bodismile/bmob-newim-demo

@Override
protected void initView() {
  super.initView();
  mTabs = new Button[3];
  mTabs[0] = btn_conversation;
  mTabs[1] = btn_contact;
  mTabs[2] =btn_set;
  mTabs[0].setSelected(true);
  initTab();
}

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

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
  ItemObject itemObject = mDataset.get(position);
  ((ViewHolder)holder).mTextView.setText(itemObject.getTitle());
  Button mButton = ((ViewHolder) holder).mButton;

  mButton.setSelected(itemObject.isSelected());
  if(itemObject.isSelected()){

    ((ViewHolder)holder).mTextView.setText("OK");
  }
  mButton.setTag(position);
  mButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      updateDatset((Integer) v.getTag());
    }
  });
}

代码示例来源:origin: EvanRespaut/Equate

private void setSelectedButtonHighlight(boolean highlighted) {
    mCallback.setEqualButtonColor(highlighted);
    //Don't color if "More" button was selected
    if (mUnitType.getCurrUnitButtonPos() < mNumConvButtons){
      int currButtonPos = mUnitType.getCurrUnitButtonPos();
      //if no button is selected, return
      if (currButtonPos == -1)
        return;
      // this fixes a bug when currency is selected and app leaves, and we
      // reload, currency is still selected and this is a null pointer
      if (currButtonPos >= mConvButton.size())
        return;

      //set the current button to highlighted or not
      mConvButton.get(currButtonPos).setSelected(highlighted);
    }
  }
}

代码示例来源:origin: VREMSoftwareDevelopment/WiFiAnalyzer

@Override
  public void execute(Pair<WiFiChannel, WiFiChannel> key) {
    Button button = (Button) views.get(key);
    verify(button).setVisibility(View.VISIBLE);
    verify(button).setBackgroundColor(selectedKey.equals(key) ? colorSelected : colorNotSelected);
    verify(button).setSelected(selectedKey.equals(key));
  }
}

相关文章

Button类方法