Java Code Examples for android.widget.Button#setText()

The following examples show how to use android.widget.Button#setText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PushSingleTopScene_0.java    From scene with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if (getActivity() != null) {
        getView().setBackgroundColor(ColorUtil.getMaterialColor(getActivity().getResources(), 1));
    }

    TextView name = getView().findViewById(R.id.name);
    name.setText(getNavigationScene().getStackHistory());

    Button btn = getView().findViewById(R.id.btn);
    btn.setText(getString(R.string.nav_single_top_btn_0));
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getNavigationScene().push(PushSingleTopScene_1.class);
        }
    });
}
 
Example 2
Source File: InstallPermissionsFragment.java    From commcare-android with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.install_permission_requester, container, false);

    TextView neededPermDetails = view.findViewById(R.id.perms_rationale_message);
    neededPermDetails.setText(Localization.get("install.perms.rationale.message"));

    Button requestPermsButton = view.findViewById(R.id.get_perms_button);
    requestPermsButton.setOnClickListener(v -> {
        RuntimePermissionRequester permissionRequester = (RuntimePermissionRequester)getActivity();
        Permissions.acquireAllAppPermissions(getActivity(), permissionRequester,
                Permissions.ALL_PERMISSIONS_REQUEST);
    });
    requestPermsButton.setText(Localization.get("permission.acquire.required"));

    return view;
}
 
Example 3
Source File: SettingsAdapter.java    From bee with Apache License 2.0 6 votes vote down vote up
private View createButton(ViewGroup parent, MethodInfo methodInfo) {

    final Method method = methodInfo.getMethod();
    final Object instance = methodInfo.getInstance();

    View view = inflater.inflate(R.layout.item_settings_button, parent, false);
    Button button = (Button) view.findViewById(R.id.button);
    button.setText(methodInfo.getTitle());
    button.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        try {
          method.invoke(instance);
        } catch (Exception e) {
          Log.e("Bee", e.getMessage());
        }
      }
    });

    return view;
  }
 
Example 4
Source File: TestBehaviours.java    From SlidingIntroScreen with Apache License 2.0 6 votes vote down vote up
/**
 * @return a Button which sets the left button to use the RequestPermission behaviour
 */
private Button createRequestPermissionButton() {
	final Button button = new Button(this);
	button.setText("Test request permission behaviour");

	button.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			getLeftButtonAccessor().setBehaviour(new IntroButton.RequestPermissions(PERMISSIONS,
					PERM_REQUEST_CODE));
			getLeftButtonAccessor().setText("Grant perms", null);
		}
	});

	return button;
}
 
Example 5
Source File: RewriteAlertController.java    From FoodOrdering with Apache License 2.0 5 votes vote down vote up
private boolean setupButton(LinearLayout layout) {
	boolean hasButton = false;
	Button_Positive = (Button) mWindow.findViewById(R.id.positive);
	Button_Negative = (Button) mWindow.findViewById(R.id.negative);
	Button_Neutral = (Button) mWindow.findViewById(R.id.neutral);

	Button_Positive.setOnClickListener(clickListener);
	Button_Negative.setOnClickListener(clickListener);
	Button_Neutral.setOnClickListener(clickListener);

	if (TextUtils.isEmpty(mPositiveTitle)) {
		Button_Positive.setVisibility(View.GONE);
	} else {
		Button_Positive.setVisibility(View.VISIBLE);
		Button_Positive.setText(mPositiveTitle);
		hasButton = true;
	}
	if (TextUtils.isEmpty(mNegativeTitle)) {
		Button_Negative.setVisibility(View.GONE);
	} else {
		Button_Negative.setVisibility(View.VISIBLE);
		Button_Negative.setText(mNegativeTitle);
		hasButton = true;
	}
	if (TextUtils.isEmpty(mNeutralTitle)) {
		Button_Neutral.setVisibility(View.GONE);
	} else {
		Button_Negative.setVisibility(View.VISIBLE);
		Button_Neutral.setText(mNeutralTitle);
		hasButton = true;
	}
	return hasButton;
}
 
Example 6
Source File: TestPageLock.java    From SlidingIntroScreen with Apache License 2.0 5 votes vote down vote up
/**
 * @return creates a Button which locks the ViewPager from commands
 */
private Button createLockCommandButton() {
	final Button button = new Button(this);
	button.setText("Lock to commands");

	button.setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			setPagingLockMode(LockableViewPager.LockMode.COMMAND_LOCKED);
		}
	});

	return button;
}
 
Example 7
Source File: ShotFragment.java    From droidddle with Apache License 2.0 5 votes vote down vote up
private void addTagButton(ViewGroup shotTagLayout, final String s) {
    Button button = (Button) LayoutInflater.from(getActivity()).inflate(R.layout.shot_tag, shotTagLayout, false);
    button.setText(s);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            UiUtils.openTagShotActivity(getActivity(), s);
        }
    });
    shotTagLayout.addView(button);
}
 
Example 8
Source File: HotStatusesActivity.java    From YiBo with Apache License 2.0 5 votes vote down vote up
private void bindEvent() {
	Button btnBack = (Button)this.findViewById(R.id.btnBack);
	btnBack.setOnClickListener(new GoBackClickListener());

	Button btnOperate = (Button) this.findViewById(R.id.btnOperate);
	btnOperate.setVisibility(View.VISIBLE);
	btnOperate.setText(R.string.btn_home);
	btnOperate.setOnClickListener(new GoHomeClickListener());
	
	ListView  lvMicroBlog = (ListView)this.findViewById(R.id.lvMicroBlog);
	lvMicroBlog.setOnItemClickListener(new MicroBlogItemClickListener(this));
	MicroBlogContextMenuListener contextMenuListener =
		new MicroBlogContextMenuListener(lvMicroBlog);
	lvMicroBlog.setOnCreateContextMenuListener(contextMenuListener);
}
 
Example 9
Source File: PlayMovieSurfaceActivity.java    From pause-resume-video-recording with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the on-screen controls to reflect the current state of the app.
 */
private void updateControls() {
    Button play = (Button) findViewById(R.id.play_stop_button);
    if (mShowStopLabel) {
        play.setText(R.string.stop_button_text);
    } else {
        play.setText(R.string.play_button_text);
    }
    play.setEnabled(mSurfaceHolderReady);
}
 
Example 10
Source File: InfiniteHorizontalFragment.java    From freepager with Apache License 2.0 5 votes vote down vote up
@Override
public View makeView(int vertical, int horizontal) {
	Button btn = new Button(getActivity());
	btn.setText("Horizontal " + horizontal);
	btn.setBackgroundColor(mBgColor);
	return btn;
}
 
Example 11
Source File: AnimationListDemoScene.java    From scene with Apache License 2.0 5 votes vote down vote up
private Button addButton(LinearLayout parent, String text, View.OnClickListener onClickListener) {
    Button button = new Button(getActivity());
    button.setAllCaps(false);
    button.setText(text);
    button.setOnClickListener(onClickListener);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 150);
    lp.leftMargin = 20;
    lp.rightMargin = 20;
    parent.addView(button, lp);
    return button;
}
 
Example 12
Source File: MainActivity.java    From XQuickEnergy with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
{
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 setModuleActive(false);

 tv_statistics = (TextView) findViewById(R.id.tv_statistics);
 btn_help = (Button) findViewById(R.id.btn_help);
 if(strArray == null)
  strArray = getResources().getStringArray(R.array.sentences);
 if(strArray != null)
  btn_help.setText(strArray[RandomUtils.nextInt(0, strArray.length)]);
}
 
Example 13
Source File: SubmissionRequestActivity.java    From JianshuApp with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Button button = new Button(this);
    button.setText("SubmissionRequestActivity");
    setContentView(button);
}
 
Example 14
Source File: MainActivity.java    From views-widgets-samples with Apache License 2.0 5 votes vote down vote up
private Button createMaterialMotionButton(String label,
        final float cx1, final float cy1, final float cx2, final float cy2,
        float weight, final ControlPointCallback callback) {
    Button button = new Button(this);
    LayoutParams params = new LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.weight = weight;
    button.setLayoutParams(params);
    button.setText("F out L in");
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Animate the control points to their new values
            final float oldCx1 = mVisualizer.getCx1();
            final float oldCy1 = mVisualizer.getCy1();
            final float oldCx2 = mVisualizer.getCx2();
            final float oldCy2 = mVisualizer.getCy2();
            ValueAnimator anim = ValueAnimator.ofFloat(0, 1).setDuration(100);
            anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    float t = valueAnimator.getAnimatedFraction();
                    mVisualizer.setCubicInterpolator(oldCx1 + t * (cx1 - oldCx1),
                            oldCy1 + t * (cy1 - oldCy1),
                            oldCx2 + t * (cx2 - oldCx2),
                            oldCy2 + t * (cy2 - oldCy2), callback);
                }
            });
            anim.start();
        }
    });
    return button;
}
 
Example 15
Source File: RcvHolder.java    From FamilyChat with Apache License 2.0 5 votes vote down vote up
/**
 * 设置button的文本
 */
public RcvHolder setBtnText(int viewId, String text)
{
    Button button = findView(viewId);
    if (button != null)
        button.setText(text);
    return this;
}
 
Example 16
Source File: ChooseTime.java    From zidoorecorder with Apache License 2.0 4 votes vote down vote up
public void getTime(Context mContext) {

		// ScreenInfo screenInfo = new ScreenInfo(mContext);//设置宽高等像素大小
		// 构造wheelMain对象
		wheelMain = new WheelMain(mTimepickerview, true);// 实例化timepickerview
															// view 控件
		// wheelMain.screenheight = screenInfo.getHeight();
		calendar = Calendar.getInstance();

		year = calendar.get(Calendar.YEAR);
		month = calendar.get(Calendar.MONTH);
		day = calendar.get(Calendar.DAY_OF_MONTH);

		houre = calendar.get(Calendar.HOUR_OF_DAY);
		minute = calendar.get(Calendar.MINUTE);
		seconds = calendar.get(Calendar.SECOND);
		wheelMain.initDateTimePicker(year, month, day, houre, minute, seconds);
		// dialog.setContentView(timepickerview);
		dialog.show();
		dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
		dialog.getWindow().setGravity(Gravity.BOTTOM);
		dialog.setContentView(mTimepickerview, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	    handler.post(updateThread);  
		// TextView tv = (TextView) timepickerview.findViewById(R.id.tv);
		// Button set = (Button) timepickerview.findViewById(R.id.set);
		// Button cancel = (Button) timepickerview.findViewById(R.id.cancel);
		btn1 = (Button) mTimepickerview.findViewById(R.id.btn1);
		btn2 = (Button) mTimepickerview.findViewById(R.id.btn2);
		btn3 = (Button) mTimepickerview.findViewById(R.id.btn3);
		btn4 = (Button) mTimepickerview.findViewById(R.id.btn4);
		btn5 = (Button) mTimepickerview.findViewById(R.id.btn5);
		btn6 = (Button) mTimepickerview.findViewById(R.id.btn6);
		SimpleDateFormat dateformat1 = new SimpleDateFormat("yyyy-MM-dd");
		mStrtime = dateformat1.format(new Date());
		btn6.setText(mStrtime);

		mbtnOnFocusChangeListener = new btnOnFocusChangeListener();
		btn1.setOnFocusChangeListener(mbtnOnFocusChangeListener);
		btn2.setOnFocusChangeListener(mbtnOnFocusChangeListener);
		btn3.setOnFocusChangeListener(mbtnOnFocusChangeListener);
		btn4.setOnFocusChangeListener(mbtnOnFocusChangeListener);
		btn5.setOnFocusChangeListener(mbtnOnFocusChangeListener);
		btn6.setOnFocusChangeListener(mbtnOnFocusChangeListener);
		
		btn1.setOnKeyListener(mBtnOnKeyListener);
		btn2.setOnKeyListener(mBtnOnKeyListener);
		btn3.setOnKeyListener(mBtnOnKeyListener);
		btn4.setOnKeyListener(mBtnOnKeyListener);
		btn5.setOnKeyListener(mBtnOnKeyListener);
		btn6.setOnKeyListener(mBtnOnKeyListener);
		
		btn6.setOnGenericMotionListener(mOnGenericMotionListener);
		btn3.setOnGenericMotionListener(mOnGenericMotionListener);
		btn4.setOnGenericMotionListener(mOnGenericMotionListener);
		btn5.setOnGenericMotionListener(mOnGenericMotionListener);
		
		btn3.setOnClickListener(mOnClickListener);
		btn4.setOnClickListener(mOnClickListener);
		btn5.setOnClickListener(mOnClickListener);
		btn6.setOnClickListener(mOnClickListener);
	}
 
Example 17
Source File: SetupWizardFragment.java    From island with Apache License 2.0 4 votes vote down vote up
private static void setButtonText(final Button button, final int text) {
	button.setEnabled(text != -1);
	if (text > 0) button.setText(text);
}
 
Example 18
Source File: AlertController.java    From PreferenceFragment with Apache License 2.0 4 votes vote down vote up
private boolean setupButtons() {
    int BIT_BUTTON_POSITIVE = 1;
    int BIT_BUTTON_NEGATIVE = 2;
    int BIT_BUTTON_NEUTRAL = 4;
    int whichButtons = 0;
    mButtonPositive = (Button) mWindow.findViewById(R.id.button1);
    mButtonPositive.setOnClickListener(mButtonHandler);

    if (TextUtils.isEmpty(mButtonPositiveText)) {
        mButtonPositive.setVisibility(View.GONE);
    } else {
        mButtonPositive.setText(mButtonPositiveText);
        mButtonPositive.setVisibility(View.VISIBLE);
        whichButtons = whichButtons | BIT_BUTTON_POSITIVE;
    }

    mButtonNegative = (Button) mWindow.findViewById(R.id.button2);
    mButtonNegative.setOnClickListener(mButtonHandler);

    if (TextUtils.isEmpty(mButtonNegativeText)) {
        mButtonNegative.setVisibility(View.GONE);
    } else {
        mButtonNegative.setText(mButtonNegativeText);
        mButtonNegative.setVisibility(View.VISIBLE);

        whichButtons = whichButtons | BIT_BUTTON_NEGATIVE;
    }

    mButtonNeutral = (Button) mWindow.findViewById(R.id.button3);
    mButtonNeutral.setOnClickListener(mButtonHandler);

    if (TextUtils.isEmpty(mButtonNeutralText)) {
        mButtonNeutral.setVisibility(View.GONE);
    } else {
        mButtonNeutral.setText(mButtonNeutralText);
        mButtonNeutral.setVisibility(View.VISIBLE);

        whichButtons = whichButtons | BIT_BUTTON_NEUTRAL;
    }

    if (shouldCenterSingleButton(mContext)) {
        /*
         * If we only have 1 button it should be centered on the layout and
         * expand to fill 50% of the available space.
         */
        if (whichButtons == BIT_BUTTON_POSITIVE) {
            centerButton(mButtonPositive);
        } else if (whichButtons == BIT_BUTTON_NEGATIVE) {
            centerButton(mButtonNegative);
        } else if (whichButtons == BIT_BUTTON_NEUTRAL) {
            centerButton(mButtonNeutral);
        }
    }
    
    return whichButtons != 0;
}
 
Example 19
Source File: Messaging.java    From GroupChat with GNU General Public License v2.0 4 votes vote down vote up
public void enableSendButton() {
	Button sendButton = (Button) this.findViewById(R.id.sendButton);
	sendButton.setEnabled(true);
	sendButton.setText("send");
}
 
Example 20
Source File: AccountViewFragment.java    From zom-android-matrix with Apache License 2.0 4 votes vote down vote up
@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.account_activity, container, false);


        mIsNewAccount = getIntent().getBooleanExtra("register", false);


        mEditUserAccount = (EditText) view.findViewById(R.id.edtName);
        mEditUserAccount.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                checkUserChanged();
            }
        });

        mEditPass = (EditText) view.findViewById(R.id.edtPass);

        mEditPassConfirm = (EditText) view.findViewById(R.id.edtPassConfirm);
        mSpinnerDomains = (AutoCompleteTextView) view.findViewById(R.id.spinnerDomains);

        if (mIsNewAccount)
        {
            mEditPassConfirm.setVisibility(View.VISIBLE);
            mSpinnerDomains.setVisibility(View.VISIBLE);
            mEditUserAccount.setHint(R.string.account_setup_new_username);

            ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
                    android.R.layout.simple_dropdown_item_1line, Server.getServersText(getActivity()));
            mSpinnerDomains.setAdapter(adapter);

        }

//        mRememberPass = (CheckBox) findViewById(R.id.rememberPassword);
  //      mUseTor = (CheckBox) findViewById(R.id.useTor);


        mBtnSignIn = (Button) view.findViewById(R.id.btnSignIn);

        if (mIsNewAccount)
            mBtnSignIn.setText(R.string.btn_create_new_account);


        //mBtnAdvanced = (Button) findViewById(R.id.btnAdvanced);
       // mBtnQrDisplay = (Button) findViewById(R.id.btnQR);

        /*
        mRememberPass.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                updateWidgetState();
            }
        });*/

        return view;

    }