android.widget.Button类的使用及代码示例

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

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

Button介绍

暂无

代码示例

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

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
    Bundle savedInstanceState) 
{
  final View view = inflater.inflate(R.layout..., container, false);

  Button button = view.findViewById(R.id...);
  button.setOnClickListener(...);

  return view;
}

代码示例来源:origin: guardianproject/haven

@Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
               @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(layoutResId, container, false);
    ((TextView)view.findViewById(R.id.custom_slide_big_text)).setText(mTitle);

    if (mButtonText != null)
    {
      Button button = view.findViewById(R.id.custom_slide_button);
      button.setVisibility(View.VISIBLE);
      button.setText(mButtonText);
      button.setOnClickListener(mButtonListener);
    }
    return view;

  }
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public View onCreateView(LayoutInflater inflater,
             ViewGroup container,
             Bundle savedInstanceState) {
 View result=inflater.inflate(R.layout.main, container, false);
 btn=(Button)result.findViewById(R.id.go);
 btn.setOnClickListener(this);
 btn.setEnabled(binding!=null);
 return(result);
}

代码示例来源:origin: k9mail/k-9

private void setShowDownloadButton(MessageViewInfo messageViewInfo) {
  if (messageViewInfo.isMessageIncomplete) {
    mDownloadRemainder.setEnabled(true);
    mDownloadRemainder.setVisibility(View.VISIBLE);
  } else {
    mDownloadRemainder.setVisibility(View.GONE);
  }
}

代码示例来源:origin: GitLqr/LQRWeChat

@Override
public void initView() {
  mBtnToolbarSend.setVisibility(View.VISIBLE);
  mBtnToolbarSend.setText(UIUtils.getString(R.string.sure));
  mBtnToolbarSend.setEnabled(false);
  mHeaderView = View.inflate(this, R.layout.header_group_cheat, null);
}

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

if (view == null) {
  LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
  view = inflater.inflate(R.layout.my_custom_list_layout, null);
TextView listItemText = (TextView)view.findViewById(R.id.list_item_string); 
listItemText.setText(list.get(position)); 
Button deleteBtn = (Button)view.findViewById(R.id.delete_btn);
Button addBtn = (Button)view.findViewById(R.id.add_btn);
deleteBtn.setOnClickListener(new View.OnClickListener(){
  @Override
  public void onClick(View v) { 
addBtn.setOnClickListener(new View.OnClickListener(){
  @Override
  public void onClick(View v) {

代码示例来源:origin: Bigkoo/Android-PickerView

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
  super.onActivityCreated(savedInstanceState);
  btnShow = (Button) mView.findViewById(R.id.btn_show);
  btnShow.setOnClickListener(this);
  mFrameLayout = (FrameLayout) mView.findViewById(R.id.fragmen_fragment);
  initTimePicker();
}

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

Button btn = (Button) convertView.findViewById(R.id.button);
btn.setOnClickListener(this);
TextView tv = (TextView) convertView.findViewById(R.id.text);
tv.setText(text);
convertView.setOnClickListener(new OnItemClickListener(position));
return convertView;

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

public class PresentActivity extends Activity {
   protected void onCreate(Bundle icicle) {
     super.onCreate(icicle);
     setContentView(R.layout.content_layout_id);
     final Button button = (Button) findViewById(R.id.button_id);
     button.setOnClickListener(new View.OnClickListener() {
       public void onClick(View v) {
         // Perform action on click   
         Intent activityChangeIntent = new Intent(PresentActivity.this, NextActivity.class);
         // currentContext.startActivity(activityChangeIntent);
         PresentActivity.this.startActivity(activityChangeIntent);
       }
     });
   }
 }

代码示例来源:origin: guardianproject/haven

private void doCancel() {
  boolean wasTimer = false;
  if (cTimer != null) {
    cTimer.cancel();
    cTimer = null;
    mOnTimerTicking = false;
    wasTimer = true;
  }
  if (mIsMonitoring) {
    mIsMonitoring = false;
    stopService(new Intent(this, MonitorService.class));
    finish();
  } else {
    findViewById(R.id.btnStartNow).setVisibility(View.VISIBLE);
    findViewById(R.id.timer_text_title).setVisibility(View.VISIBLE);
    ((Button) findViewById(R.id.btnStartLater)).setText(R.string.start_later);
    int timeM = preferences.getTimerDelay() * 1000;
    txtTimer.setText(getTimerText(timeM));
    if (!wasTimer)
      finish();
  }
}

代码示例来源:origin: yanzhenjie/NoHttp

@Override
public void onError(String message) {
  mBtnOperation.setText(R.string.download_start);
  mTvStatus.setText(R.string.download_status_error);
}

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

TextView txtName = (TextView) convertView.findViewById(R.id.nameEdit);
txtName.setText(score.getName());
Button b = (Button)convertView.findViewById(R.id.deletePlayer);
b.setTag(position);
b.setOnClickListener(new View.OnClickListener() {
     public void onClick(View v) {

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

public class ViewDialog {

  public void showDialog(Activity activity, String msg){
    final Dialog dialog = new Dialog(activity);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCancelable(false);
    dialog.setContentView(R.layout.dialog);

    TextView text = (TextView) dialog.findViewById(R.id.text_dialog);
    text.setText(msg);

    Button dialogButton = (Button) dialog.findViewById(R.id.btn_dialog);
    dialogButton.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        dialog.dismiss();
      }
    });

    dialog.show();

  }
}

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

public class StartFragment extends Fragment implements OnClickListener{

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_start, container, false);

    Button b = (Button) v.findViewById(R.id.StartButton);
    b.setOnClickListener(this);
    return v;
  }

  @Override
  public void onClick(View v) {
    switch (v.getId()) {
    case R.id.StartButton:

      ...

      break;
    }
  }
}

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

btn.setOnClickListener(this);
switch (view.getId()) {
case R.id.button1:
  new LongOperation().execute("");
protected void onPostExecute(String result) {
  TextView txt = (TextView) findViewById(R.id.output);
  txt.setText("Executed"); // txt.setText(result);

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

subLayout.setLayoutParams(params);
 topLayout.setOnTouchListener(new OnTouchListener() {
buttonSwitch.setOnClickListener(new View.OnClickListener() {  
    buttonSwitch.setClickable(false);
    topLayout.setEnabled(false);
      topLayout.layout(oldLeft, oldTop, oldLeft + topLayout.getMeasuredWidth(), oldTop + topLayout.getMeasuredHeight() );
      menuOpen = false;
      buttonSwitch.setClickable(true);
      topLayout.setEnabled(true);
    } else if(menuOpen == false) {
      topLayout.setEnabled(true);
      menuOpen = true;
      buttonSwitch.setClickable(true);

代码示例来源:origin: guardianproject/haven

private void initActiveLayout() {
  ((Button) findViewById(R.id.btnStartLater)).setText(R.string.action_cancel);
  findViewById(R.id.btnStartNow).setVisibility(View.INVISIBLE);
  findViewById(R.id.timer_text_title).setVisibility(View.INVISIBLE);
  txtTimer.setText(R.string.status_on);
  mOnTimerTicking = false;
  mIsMonitoring = true;
}

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

title = (TextView) itemView.findViewById(R.id.card_view_title);
button1 = (Button) itemView.findViewById(R.id.card_view_button1);
button2 = (Button) itemView.findViewById(R.id.card_view_button2);
button1.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
button2.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
itemView.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {

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

View v = inflater.inflate(R.layout.player_password, container, false);
 passwordEdit = (EditText)v.findViewById(R.id.player_password_edit);
 okButton = (Button)v.findViewById(R.id.ok_button);
 okButton.setOnClickListener(new View.OnClickListener(){
  public void onClick(View v){
   passwordEntered();
playerListFragment.joinPlayer(toJoin, passwordEdit.getText().toString());
dismiss();

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

public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);
 final EditText TextEdit = (EditText) findViewById(R.id.TextEdit);  
 final TextView mix =(TextView) findViewById(R.id.mix);
 final Button button = (Button) findViewById(R.id.proces);
 button.setOnClickListener(new View.OnClickListener() {
   public void onClick(View v) {
     String s = shuffle(TextEdit.getText().toString());
     mix.setText(s);
   }

相关文章

Button类方法