本文整理了Java中android.widget.Button.getText()
方法的一些代码示例,展示了Button.getText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.getText()
方法的具体详情如下:
包路径:android.widget.Button
类名称:Button
方法名:getText
暂无
代码示例来源:origin: k9mail/k-9
public String getAlias() {
String alias = mSelection.getText().toString();
if (alias.equals(mActivity.getString(R.string.client_certificate_spinner_empty))) {
return null;
} else {
return alias;
}
}
代码示例来源:origin: zaaach/CityPicker
@Override
public void onClick(View v) {
if (themeBtn.getText().toString().startsWith("自定义")){
themeBtn.setText("默认主题");
theme = R.style.DefaultCityPickerTheme;
}else if (themeBtn.getText().toString().startsWith("默认")){
themeBtn.setText("自定义主题");
theme = R.style.CustomTheme;
}
recreate();
}
});
代码示例来源:origin: journeyapps/zxing-android-embedded
public void switchFlashlight(View view) {
if (getString(R.string.turn_on_flashlight).equals(switchFlashlightButton.getText())) {
barcodeScannerView.setTorchOn();
} else {
barcodeScannerView.setTorchOff();
}
}
代码示例来源:origin: yuliskov/SmartYouTubeTV
public CharSequence getText() {
return mTextButton.getText();
}
代码示例来源:origin: airbnb/epoxy
@Test
public void fullyCreateDataBindingModel() {
SimpleEpoxyController controller = new SimpleEpoxyController();
ModelWithDataBindingBindingModel_ firstModel = new ModelWithDataBindingBindingModel_()
.stringValue("hello")
.id(1);
controller.setModels(Collections.singletonList(firstModel));
ControllerLifecycleHelper lifecycleHelper = new ControllerLifecycleHelper();
EpoxyViewHolder viewHolder = lifecycleHelper.createViewHolder(controller.getAdapter(), 0);
controller.getAdapter().onBindViewHolder(viewHolder, 0);
DataBindingHolder dataBindingHolder = ((DataBindingHolder) viewHolder.objectToBind());
assertNotNull(dataBindingHolder.getDataBinding());
// Check that the requiredText was set on the view
assertEquals(firstModel.stringValue(), ((Button) viewHolder.itemView).getText());
ModelWithDataBindingBindingModel_ secondModel = new ModelWithDataBindingBindingModel_()
.stringValue("hello again")
.id(1);
controller.setModels(Collections.singletonList(secondModel));
List<Object> payloads = DiffPayloadTestUtil.payloadsWithChangedModels(firstModel);
controller.getAdapter().onBindViewHolder(viewHolder, 0, payloads);
// Check that the requiredText was updated after the change payload
assertEquals(secondModel.stringValue(), ((Button) viewHolder.itemView).getText());
}
代码示例来源:origin: airbnb/epoxy
@Test
public void createDataBindingModel() {
SimpleEpoxyController controller = new SimpleEpoxyController();
ModelWithDataBindingBindingModel_ firstModel = new ModelWithDataBindingBindingModel_()
.stringValue("hello")
.id(1);
controller.setModels(Collections.singletonList(firstModel));
ControllerLifecycleHelper lifecycleHelper = new ControllerLifecycleHelper();
EpoxyViewHolder viewHolder = lifecycleHelper.createViewHolder(controller.getAdapter(), 0);
controller.getAdapter().onBindViewHolder(viewHolder, 0);
DataBindingHolder dataBindingHolder = ((DataBindingHolder) viewHolder.objectToBind());
assertNotNull(dataBindingHolder.getDataBinding());
// Check that the requiredText was set on the view
assertEquals(firstModel.stringValue(), ((Button) viewHolder.itemView).getText());
ModelWithDataBindingBindingModel_ secondModel = new ModelWithDataBindingBindingModel_()
.stringValue("hello again")
.id(1);
controller.setModels(Collections.singletonList(secondModel));
List<Object> payloads = DiffPayloadTestUtil.payloadsWithChangedModels(firstModel);
controller.getAdapter().onBindViewHolder(viewHolder, 0, payloads);
// Check that the requiredText was updated after the change payload
assertEquals(secondModel.stringValue(), ((Button) viewHolder.itemView).getText());
}
代码示例来源:origin: ogaclejapan/ArcLayout
private void showToast(Button btn) {
if (toast != null) {
toast.cancel();
}
String text = "Clicked: " + btn.getText();
toast = Toast.makeText(this, text, Toast.LENGTH_SHORT);
toast.show();
}
代码示例来源:origin: ogaclejapan/ArcLayout
private void showToast(Button btn) {
if (toast != null) {
toast.cancel();
}
String text = "Clicked: " + btn.getText();
toast = Toast.makeText(this, text, Toast.LENGTH_SHORT);
toast.show();
}
}
代码示例来源:origin: ogaclejapan/ArcLayout
private void showToast(Button btn) {
if (toast != null) {
toast.cancel();
}
String text = "Clicked: " + btn.getText();
toast = Toast.makeText(this, text, Toast.LENGTH_SHORT);
toast.show();
}
代码示例来源:origin: ogaclejapan/ArcLayout
private void showToast(Button btn) {
if (toast != null) {
toast.cancel();
}
String text = "Clicked: " + btn.getText();
toast = Toast.makeText(this, text, Toast.LENGTH_SHORT);
toast.show();
}
}
代码示例来源:origin: ukanth/afwall
if (profButton1.getText().equals(profileName)) {
profButton1.setEnabled(false);
profButton2.setEnabled(true);
profButton3.setEnabled(true);
} else if (profButton2.getText().equals(profileName)) {
profButton1.setEnabled(true);
profButton2.setEnabled(false);
profButton3.setEnabled(true);
} else if (profButton3.getText().equals(profileName)) {
profButton1.setEnabled(true);
profButton2.setEnabled(true);
代码示例来源:origin: ukanth/afwall
@Override
public void onClick(View button) {
profileName = ((Button) button).getText().toString();
buttonId = button.getId();
SecurityUtil util = new SecurityUtil(ToggleWidgetOldActivity.this);
boolean passCheck = util.isPasswordProtected();
if (!passCheck) {
switchAction();
} else {
util.passCheck();
}
}
代码示例来源:origin: heinrichreimer/material-intro
miButtonCta.setVisibility(View.VISIBLE);
if (!((Button) miButtonCta.getCurrentView()).getText().equals(buttonNext.first))
miButtonCta.setText(buttonNext.first);
miButtonCta.getChildAt(0).setOnClickListener(buttonNext.second);
miButtonCta.setVisibility(View.VISIBLE);
if (!((Button) miButtonCta.getCurrentView()).getText().equals(button.first))
miButtonCta.setText(button.first);
miButtonCta.getChildAt(0).setOnClickListener(button.second);
if (!((Button) miButtonCta.getCurrentView()).getText().equals(buttonNext.first))
miButtonCta.setText(buttonNext.first);
miButtonCta.getChildAt(0).setOnClickListener(buttonNext.second);
miButtonCta.getChildAt(1).setOnClickListener(buttonNext.second);
} else {
if (!((Button) miButtonCta.getCurrentView()).getText().equals(button.first))
miButtonCta.setText(button.first);
miButtonCta.getChildAt(0).setOnClickListener(button.second);
代码示例来源:origin: labexp/osmtracker-android
@Override
public void onClick(View view) {
Button button = (Button) view;
String label = button.getText().toString().replaceAll("\n", " ");
// Send an intent to inform service to track the waypoint.
Intent intent = new Intent(OSMTracker.INTENT_TRACK_WP);
intent.putExtra(TrackContentProvider.Schema.COL_TRACK_ID, currentTrackId);
intent.putExtra(OSMTracker.INTENT_KEY_NAME, label);
view.getContext().sendBroadcast(intent);
// Inform user that the waypoint was tracked
Toast.makeText(view.getContext(), view.getContext().getResources().getString(R.string.tracklogger_tracked) + " " + label, Toast.LENGTH_SHORT).show();
}
代码示例来源:origin: zulip/zulip-android
@Override
public void onClick(View v) {
authClickListener.onItemClick(((Button) v).getText().toString());
}
}
代码示例来源:origin: LiqiNew/MyUtils
@Override
public void onClick(View v) {
Button button = (Button) v;
String content = button.getText().toString().split(":")[1];
String md5Encode = MD5Util.md5Encode(content, "utf-8");
button.setText("MD5加密后内容:" + md5Encode);
}
});
代码示例来源:origin: zulip/zulip-android
@Override
protected boolean matchesSafely(Button item) {
if (!matchedBefore && item.getText().toString().contains("@")) {
EMAIL_TEST = item.getText().toString();
matchedBefore = true;
return true;
}
return false;
}
};
代码示例来源:origin: captain-miao/AndroidAgeraTutorial
@Override
public void onClick(View v) {
if(v instanceof Button) {
String name = ((Button) v).getText().toString();
ActivityNavigation.from(this).toUri(mActInfoMap.get(name).getUrl());
}
}
代码示例来源:origin: VREMSoftwareDevelopment/WiFiAnalyzer
@Override
public void execute(Pair<WiFiChannel, WiFiChannel> key) {
Integer id = ChannelGraphNavigation.ids.get(key);
Button button = mock(Button.class);
views.put(key, button);
when(layout.findViewById(id)).thenReturn(button);
when(button.getText()).thenReturn("ButtonName");
}
}
代码示例来源:origin: ravidsrk/android-testing-guide
@Test @Ignore
public void clickButton() {
Button button = activity.findViewById(R.id.button);
assertNotNull("test button could not be found", button);
assertTrue("button does not contain text 'Click Me!'", "Click Me".equals(button.getText()));
}
内容来源于网络,如有侵权,请联系作者删除!