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

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

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

Button.getVisibility介绍

暂无

代码示例

代码示例来源:origin: TangoAgency/material-intro-screen

private void showMessageButton(final SlideFragment fragment) {
    if (messageButton.getVisibility() != View.VISIBLE) {
      messageButton.setVisibility(View.VISIBLE);
      if (fragment.getActivity() != null) {
        messageButton.startAnimation(AnimationUtils.loadAnimation(fragment.getActivity(), R.anim.fade_in));

      }
    }
  }
}

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

private void updateSubscribeButton(boolean isSubscribed) {
  if (DEBUG) Log.d(TAG, "updateSubscribeButton() called with: isSubscribed = [" + isSubscribed + "]");
  boolean isButtonVisible = headerSubscribeButton.getVisibility() == View.VISIBLE;
  int backgroundDuration = isButtonVisible ? 300 : 0;
  int textDuration = isButtonVisible ? 200 : 0;
  int subscribeBackground = ContextCompat.getColor(activity, R.color.subscribe_background_color);
  int subscribeText = ContextCompat.getColor(activity, R.color.subscribe_text_color);
  int subscribedBackground = ContextCompat.getColor(activity, R.color.subscribed_background_color);
  int subscribedText = ContextCompat.getColor(activity, R.color.subscribed_text_color);
  if (!isSubscribed) {
    headerSubscribeButton.setText(R.string.subscribe_button_title);
    animateBackgroundColor(headerSubscribeButton, backgroundDuration, subscribedBackground, subscribeBackground);
    animateTextColor(headerSubscribeButton, textDuration, subscribedText, subscribeText);
  } else {
    headerSubscribeButton.setText(R.string.subscribed_button_title);
    animateBackgroundColor(headerSubscribeButton, backgroundDuration, subscribeBackground, subscribedBackground);
    animateTextColor(headerSubscribeButton, textDuration, subscribeText, subscribedText);
  }
  animateView(headerSubscribeButton, AnimationUtils.Type.LIGHT_SCALE_AND_ALPHA, true, 100);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldOnlyCreateRequestedButtons() throws Exception {
 AlertDialog.Builder builder = new AlertDialog.Builder(application);
 builder.setPositiveButton("OK", null);
 AlertDialog dialog = builder.create();
 dialog.show();
 assertThat(dialog.getButton(AlertDialog.BUTTON_POSITIVE).getVisibility())
   .isEqualTo(View.VISIBLE);
 assertThat(dialog.getButton(AlertDialog.BUTTON_NEGATIVE).getVisibility()).isEqualTo(View.GONE);
}

代码示例来源:origin: TangoAgency/material-intro-screen

@Override
public void pageSelected(int position) {
  final SlideFragment slideFragment = adapter.getItem(position);
  if (slideFragment.hasAnyPermissionsToGrant()) {
    showMessageButton(slideFragment);
    messageButton.setText(slideFragment.getActivity().getString(R.string.grant_permissions));
    messageButton.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
        slideFragment.askForPermissions();
      }
    });
  } else if (checkIfMessageButtonHasBehaviour(position)) {
    showMessageButton(slideFragment);
    messageButton.setText(messageButtonBehaviours.get(position).getMessageButtonText());
    messageButton.setOnClickListener(messageButtonBehaviours.get(position).getClickListener());
  } else if (messageButton.getVisibility() != View.INVISIBLE) {
    messageButton.startAnimation(AnimationUtils.loadAnimation(slideFragment.getContext(), R.anim.fade_out));
    messageButton.setVisibility(View.INVISIBLE);
  }
}

代码示例来源:origin: FolioReader/FolioReader-Android

private void loadWikipedia() {
  if (noNetwork.getVisibility() == View.VISIBLE || googleSearch.getVisibility() == View.VISIBLE) {
    noNetwork.setVisibility(View.GONE);
    googleSearch.setVisibility(View.GONE);
  }
  wikiWebView.loadUrl("about:blank");
  mAdapter.clear();
  wikiLayout.setVisibility(View.VISIBLE);
  dictResults.setVisibility(View.GONE);
  dictionary.setSelected(false);
  wikipedia.setSelected(true);
  WikipediaTask task = new WikipediaTask(this);
  String urlString = null;
  try {
    urlString = Constants.WIKIPEDIA_API_URL + URLEncoder.encode(word, "UTF-8");
  } catch (UnsupportedEncodingException e) {
    Log.e(TAG, "-> loadWikipedia", e);
  }
  task.execute(urlString);
}

代码示例来源:origin: FolioReader/FolioReader-Android

private void loadDictionary() {
  if (noNetwork.getVisibility() == View.VISIBLE || googleSearch.getVisibility() == View.VISIBLE) {
    noNetwork.setVisibility(View.GONE);
    googleSearch.setVisibility(View.GONE);
  }
  wikiWebView.loadUrl("about:blank");
  mAdapter.clear();
  dictionary.setSelected(true);
  wikipedia.setSelected(false);
  wikiLayout.setVisibility(View.GONE);
  dictResults.setVisibility(View.VISIBLE);
  DictionaryTask task = new DictionaryTask(this);
  String urlString = null;
  try {
    urlString = Constants.DICTIONARY_BASE_URL + URLEncoder.encode(word, "UTF-8");
  } catch (UnsupportedEncodingException e) {
    Log.e(TAG, "-> loadDictionary", e);
  }
  task.execute(urlString);
}

代码示例来源:origin: brarcher/video-transcoder

private boolean isEncoding()
{
  return cancelButton.getVisibility() == View.VISIBLE;
}

代码示例来源:origin: TobiasBielefeld/Simple-Solitaire

public void hideButton() {
  buttonShown = false;
  if (gm.buttonAutoComplete.getVisibility() == View.VISIBLE) {
    gm.buttonAutoComplete.setVisibility(View.GONE);
  }
}

代码示例来源:origin: intrications/intent-intercept

@Override
protected void onSaveInstanceState(Bundle outState) {
  super.onSaveInstanceState(outState);
  outState.putBoolean(INTENT_EDITED,
      resetIntentButton.getVisibility() == View.VISIBLE);
}

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

public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.mylayout);

  Button testButton=(Button)findViewById(R.id.testButtonId);
      if (testButton.getVisibility()==View.VISIBLE){
        testButton.setVisibility(View.GONE);
      }else {
         testButton.setVisibility(View.VISIBLE);
      }

}

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

listView.setOnItemClickListener(new OnItemClickListener() {
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Button b = (Button) view.findViewById(R.id.button_id);
    if(b.getVisibility() == View.VISIBLE)
      b.setVisibility(View.INVISIBLE);
    else
      b.setVisibility(View.VISIBLE);

  }
});

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

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
  if (!TextUtils.isEmpty(s)) {
    btn_chat_send.setVisibility(View.VISIBLE);
    btn_chat_keyboard.setVisibility(View.GONE);
    btn_chat_voice.setVisibility(View.GONE);
  } else {
    if (btn_chat_voice.getVisibility() != View.VISIBLE) {
      btn_chat_voice.setVisibility(View.VISIBLE);
      btn_chat_send.setVisibility(View.GONE);
      btn_chat_keyboard.setVisibility(View.GONE);
    }
  }
}

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

@Override
public void onResume()
{
  super.onResume();
  if (snapshotButton.getVisibility() == View.VISIBLE)
  {
    startFadeOutTimer(false);
  }
}

代码示例来源:origin: the-pig-of-jungle/SmartShow

@Override
public void animateContentIn(int delay, int duration) {
  mMessageView.setAlpha(0f);
  mMessageView.animate().alpha(1f).setDuration(duration)
      .setStartDelay(delay).start();
  if (mActionView.getVisibility() == VISIBLE) {
    mActionView.setAlpha(0f);
    mActionView.animate().alpha(1f).setDuration(duration)
        .setStartDelay(delay).start();
  }
}

代码示例来源:origin: the-pig-of-jungle/smart-show

@Override
public void animateContentIn(int delay, int duration) {
  mMessageView.setAlpha(0f);
  mMessageView.animate().alpha(1f).setDuration(duration)
      .setStartDelay(delay).start();
  if (mActionView.getVisibility() == VISIBLE) {
    mActionView.setAlpha(0f);
    mActionView.animate().alpha(1f).setDuration(duration)
        .setStartDelay(delay).start();
  }
}

代码示例来源:origin: the-pig-of-jungle/SmartShow

@Override
  public void animateContentOut(int delay, int duration) {
    mMessageView.setAlpha(1f);
    mMessageView.animate().alpha(0f).setDuration(duration)
        .setStartDelay(delay).start();

    if (mActionView.getVisibility() == VISIBLE) {
      mActionView.setAlpha(1f);
      mActionView.animate().alpha(0f).setDuration(duration)
          .setStartDelay(delay).start();
    }
  }
}

代码示例来源:origin: the-pig-of-jungle/smart-show

@Override
  public void animateContentOut(int delay, int duration) {
    mMessageView.setAlpha(1f);
    mMessageView.animate().alpha(0f).setDuration(duration)
        .setStartDelay(delay).start();

    if (mActionView.getVisibility() == VISIBLE) {
      mActionView.setAlpha(1f);
      mActionView.animate().alpha(0f).setDuration(duration)
          .setStartDelay(delay).start();
    }
  }
}

代码示例来源:origin: rafaeltoledo/unified-code-coverage-android

@Test
  public void shouldHideButtonAfterClick() {
    MainActivity activity = Robolectric.setupActivity(MainActivity.class);

    Button button = activity.findViewById(R.id.hide);
    button.performClick();

    assertThat(button.getVisibility(), is(View.GONE));
  }
}

代码示例来源:origin: HuanHaiLiuXin/SweetTips

void animateChildrenOut(int delay, int duration) {
  ViewCompat.setAlpha(mMessageView, 1f);
  ViewCompat.animate(mMessageView).alpha(0f).setDuration(duration)
      .setStartDelay(delay).start();
  if (mActionView.getVisibility() == VISIBLE) {
    ViewCompat.setAlpha(mActionView, 1f);
    ViewCompat.animate(mActionView).alpha(0f).setDuration(duration)
        .setStartDelay(delay).start();
  }
}

代码示例来源:origin: HuanHaiLiuXin/SweetTips

void animateChildrenIn(int delay, int duration) {
  ViewCompat.setAlpha(mMessageView, 0f);
  ViewCompat.animate(mMessageView).alpha(1f).setDuration(duration)
      .setStartDelay(delay).start();
  if (mActionView.getVisibility() == VISIBLE) {
    ViewCompat.setAlpha(mActionView, 0f);
    ViewCompat.animate(mActionView).alpha(1f).setDuration(duration)
        .setStartDelay(delay).start();
  }
}

相关文章

Button类方法