本文整理汇总了Java中android.widget.Button.setText方法的典型用法代码示例。如果您正苦于以下问题:Java Button.setText方法的具体用法?Java Button.setText怎么用?Java Button.setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.Button
的用法示例。
在下文中一共展示了Button.setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateTopBarTextButton
import android.widget.Button; //导入方法依赖的package包/类
/**
* 生成一个文本按钮,并设置文字
*
* @param text 按钮的文字
* @return
*/
private Button generateTopBarTextButton(String text) {
Button button = new Button(getContext());
button.setBackgroundResource(0);
button.setMinWidth(0);
button.setMinHeight(0);
button.setMinimumWidth(0);
button.setMinimumHeight(0);
int paddingHorizontal = getTopBarTextBtnPaddingHorizontal();
button.setPadding(paddingHorizontal, 0, paddingHorizontal, 0);
button.setTextColor(QMUIResHelper.getAttrColorStateList(getContext(), R.attr.qmui_topbar_text_btn_color_state_list));
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, QMUIResHelper.getAttrDimen(getContext(), R.attr.qmui_topbar_text_btn_text_size));
button.setGravity(Gravity.CENTER);
button.setText(text);
return button;
}
示例2: createUseListBodyButton
import android.widget.Button; //导入方法依赖的package包/类
/**
* Creates a button which can be clicked to set the body of the test view to a new {@link
* ListBody}.
*
* @return the button, not null
*/
private Button createUseListBodyButton() {
final Button b = new Button(this);
b.setText("Use list body");
b.setAllCaps(false);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final ListBody body = new ListBody(CoordinatedMixtapeContainerTestHarness.this);
body.setItems(bodyItems);
body.setTitleDataBinder(new TitleBinder(titleCache, defaults));
body.setSubtitleDataBinder(new SubtitleBinder(subtitleCache, defaults));
body.setArtworkDataBinder(new ArtworkBinder(artworkCache, defaults));
testView.setBody(body);
}
});
return b;
}
示例3: createMoveItemButton
import android.widget.Button; //导入方法依赖的package包/类
/**
* Creates a button which can be clicked to swap the first two items in the test view.
*
* @return the button, not null
*/
private Button createMoveItemButton() {
final Button b = new Button(this);
b.setText("Swap first two items");
b.setAllCaps(false);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
if (items.size() > 1) {
final LibraryItem item = items.get(0);
items.remove(0);
items.add(1, item);
getTestView().notifyItemMoved(0, 1);
}
}
});
return b;
}
示例4: createRemoveItemButton
import android.widget.Button; //导入方法依赖的package包/类
/**
* Creates a button which can be clicked to remove the first item in the test view.
*
* @return the button, not null
*/
private Button createRemoveItemButton() {
final Button b = new Button(this);
b.setText("Remove item 0");
b.setAllCaps(false);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
if (items.size() > 0) {
items.remove(0);
getTestView().notifyItemRemoved(0);
}
}
});
return b;
}
示例5: onCreate
import android.widget.Button; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bt_jump= (Button) this.findViewById(R.id.bt_jump);
bt_jump.setText("发送事件");
bt_jump.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
OttoBus.getInstance().post(new BusData("刘望舒的博客更新了"));
finish();
}
});
bus=OttoBus.getInstance();
bus.register(this);
}
示例6: onCreate
import android.widget.Button; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv_message= (TextView) this.findViewById(R.id.tv_message);
bt_jump= (Button) this.findViewById(R.id.bt_jump);
bt_jump.setText("跳转到SecondActivity");
bt_jump.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this,SecondActivity.class));
}
});
bus=OttoBus.getInstance();
bus.register(this);
}
示例7: makeList
import android.widget.Button; //导入方法依赖的package包/类
public void makeList(){
if(remarks.size() > 0){
tv_msg.setVisibility(View.GONE);
}else{
tv_msg.setVisibility(View.VISIBLE);
setFadeInAnimation(tv_msg);
}
li_symptom.removeAllViews();
for(int i=0; i<remarks.size(); i++){
PatientRemark patientRemark = remarks.get(i);
View v = getLayoutInflater().inflate(R.layout.patient_remark_list_custom_item, null, false);
TextView tv_title = (TextView)v.findViewById(R.id.tv_title);
Button btn_select = (Button)v.findViewById(R.id.btn_select);
tv_title.setText(patientRemark.getDescription());
btn_select.setBackgroundResource(R.drawable.two_btn_active_right_radius_red);
btn_select.setText(R.string.delete_srt);
btn_select.setTag(i);
btn_select.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int tag = (int)view.getTag();
remarks.remove(tag);
makeList();
}
});
li_symptom.addView(v);
}
}
示例8: setupSrvaQuickButton
import android.widget.Button; //导入方法依赖的package包/类
private void setupSrvaQuickButton(Button button, final SrvaEvent event) {
Species species = SpeciesInformation.getSpecies(event.gameSpeciesCode);
if (isAdded() && species != null) {
String type = ObservationStrings.get(getActivity(), event.eventType);
button.setText(species.mName + " / " + type);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startSrvaEditActivity(event.eventName, event.eventType, event.gameSpeciesCode);
}
});
}
}
示例9: onResolved
import android.widget.Button; //导入方法依赖的package包/类
@Resolve
private void onResolved() {
mQuestionTextView.setText(mQuestionCardData.question.questionText);
if (mQuestionCardData.mShowCorrectOptions) {
showCorrectOptions();
}
for (int i = 0; i < 3; i++) {
Button button = null;
switch (i) {
case 0:
button = mOption1Button;
break;
case 1:
button = mOption2Button;
break;
case 2:
button = mOption3Button;
break;
}
if (button != null)
button.setText(mQuestionCardData.options.get(i).optionText);
if (mQuestionCardData.question.imgUrl != null) {
mPicImageView.setImageUrl(mQuestionCardData.question.imgUrl);
}
}
}
示例10: onBindView
import android.widget.Button; //导入方法依赖的package包/类
@Override
protected void onBindView(View view) {
super.onBindView(view);
Button button = (Button) view.findViewById(R.id.button_preference);
button.setText(this.getTitle());
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (getOnPreferenceClickListener() != null) {
getOnPreferenceClickListener().onPreferenceClick(ButtonPreference.this);
}
}
});
}
示例11: getViewAt
import android.widget.Button; //导入方法依赖的package包/类
public View getViewAt(int position) {
if (mViews[position] != null) return mViews[position];
switch (position) {
case 0:
mViews[position] = View.inflate(mContext, R.layout.floating_pref, null);
setUpPref(mViews[position]);
break;
case 1:
mViews[position] = View.inflate(mContext, R.layout.floating_history, null);
RecyclerView historyView = mViews[position].findViewById(R.id.history);
setUpHistory(historyView);
// This is the first time loading the history panel -- disable it until the user moves to it
setEnabled(mViews[position], false);
break;
case 2:
mViews[position] = View.inflate(mContext, R.layout.pad_basic, null);
Button dot = mViews[position].findViewById(R.id.dec_point);
dot.setText(String.valueOf(Constants.DECIMAL_POINT));
break;
case 3:
mViews[position] = View.inflate(mContext, R.layout.pad_advanced, null);
// This is the first time loading the advanced panel -- disable it until the user moves to it
setEnabled(mViews[position], false);
break;
}
applyListener(mViews[position]);
return mViews[position];
}
示例12: onResolved
import android.widget.Button; //导入方法依赖的package包/类
@Resolve
private void onResolved() {
mQuestionTextView.setText(mQuestion.getQuestionText());
for (int i = 0; i < 3; i++) {
Button button = null;
switch (i) {
case 0:
button = mOption1Button;
break;
case 1:
button = mOption2Button;
break;
case 2:
button = mOption3Button;
break;
}
if (button != null)
button.setText(mQuestion.getOptionList().get(i).getOptionText());
if (mQuestion.getImgUrl() != null) {
mPicImageView.setImageUrl(mQuestion.getImgUrl());
}
}
}
示例13: attachToPositiveButton
import android.widget.Button; //导入方法依赖的package包/类
/**
* Attach to the positive action button of the WelcomeFragmentContainer.
*
* @param button the ui element to attach to.
*/
protected void attachToPositiveButton(Button button) {
// Set the button text
button.setText(getPositiveText());
// Set the click listener
button.setOnClickListener(getPositiveListener());
}
示例14: onCreate
import android.widget.Button; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.simple);
name = (TextView) findViewById(R.id.name);
btn = (Button) findViewById(R.id.btn);
name.setText(title());
btn.setText(btnTxt());
}
示例15: create
import android.widget.Button; //导入方法依赖的package包/类
/**验证返回对话框布局*/
public static LinearLayout create(Context context) {
SizeHelper.prepare(context);
LinearLayout root = new LinearLayout(context);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
root.setLayoutParams(params);
root.setOrientation(LinearLayout.VERTICAL);
TextView dialogHint = new TextView(context);
dialogHint.setId(ResHelper.getIdRes(context, "tv_dialog_hint"));
LinearLayout.LayoutParams hintParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
hintParams.topMargin = SizeHelper.fromPxWidth(32);
hintParams.bottomMargin = SizeHelper.fromPxWidth(32);
dialogHint.setLayoutParams(hintParams);
dialogHint.setPadding(SizeHelper.fromPxWidth(18), 0, SizeHelper.fromPxWidth(18), 0);
dialogHint.setLineSpacing(SizeHelper.fromPxWidth(8), 1);
int resid = ResHelper.getStringRes(context, "smssdk_make_sure_mobile_detail");
dialogHint.setText(resid);
dialogHint.setTextColor(0xffffffff);
dialogHint.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(26));
dialogHint.setGravity(Gravity.CENTER);
root.addView(dialogHint);
View line = new View(context);
LinearLayout.LayoutParams lineParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
SizeHelper.fromPxWidth(1));
line.setLayoutParams(lineParams);
line.setBackgroundColor(0xff737373);
root.addView(line);
LinearLayout wrapper = new LinearLayout(context);
LinearLayout.LayoutParams wrapperParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
wrapper.setLayoutParams(wrapperParams);
Button ok = new Button(context);
ok.setId(ResHelper.getIdRes(context, "btn_dialog_ok"));
LinearLayout.LayoutParams okParams = new LinearLayout.LayoutParams(0,SizeHelper.fromPxWidth(78),1);
okParams.leftMargin = SizeHelper.fromPxWidth(3);
ok.setLayoutParams(okParams);
resid = ResHelper.getBitmapRes(context, "smssdk_dialog_btn_back");
ok.setBackgroundResource(resid);
int padding = SizeHelper.fromPxWidth(8);
ok.setPadding(padding, padding, padding, padding);
resid = ResHelper.getStringRes(context, "smssdk_ok");
ok.setText(resid);
ok.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(22));
ok.setTextColor(0xffffffff);
wrapper.addView(ok);
View line2 = new View(context);
LinearLayout.LayoutParams line2Params = new LinearLayout.LayoutParams(SizeHelper.fromPxWidth(1),
LinearLayout.LayoutParams.MATCH_PARENT);
line2.setLayoutParams(line2Params);
line2.setBackgroundColor(0xff737373);
wrapper.addView(line2);
Button cancel = new Button(context);
cancel.setId(ResHelper.getIdRes(context, "btn_dialog_cancel"));
LinearLayout.LayoutParams cancelParams = new LinearLayout.LayoutParams(0,SizeHelper.fromPxWidth(78),1);
cancelParams.rightMargin = SizeHelper.fromPxWidth(3);
cancel.setLayoutParams(cancelParams);
resid = ResHelper.getBitmapRes(context, "smssdk_dialog_btn_back");
cancel.setBackgroundResource(resid);
cancel.setPadding(padding, padding, padding, padding);
resid = ResHelper.getStringRes(context, "smssdk_cancel");
cancel.setText(resid);
cancel.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(22));
cancel.setTextColor(0xffffffff);
wrapper.addView(cancel);
root.addView(wrapper);
return root;
}