Java Code Examples for androidx.appcompat.widget.AppCompatButton#setText()
The following examples show how to use
androidx.appcompat.widget.AppCompatButton#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: MonitorFragment.java From onpc with GNU General Public License v3.0 | 6 votes |
private void updateMultiroomChannelBtn(AppCompatButton b, @Nullable final State state) { MultiroomDeviceInformationMsg.ChannelType ch = state != null ? state.multiroomChannel : MultiroomDeviceInformationMsg.ChannelType.NONE; if (ch != MultiroomDeviceInformationMsg.ChannelType.NONE && isGroupMenu()) { final MultiroomChannelSettingMsg cmd = new MultiroomChannelSettingMsg( state.getActiveZone() + 1, MultiroomChannelSettingMsg.getUpType(ch)); b.setVisibility(View.VISIBLE); b.setText(ch.toString()); setButtonEnabled(b, state.isOn()); final Drawable icon = Utils.getDrawable(activity, R.drawable.cmd_multiroom_channel); Utils.setDrawableColorAttr(activity, icon, state.isOn() ? R.attr.colorButtonEnabled : R.attr.colorButtonDisabled); b.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); prepareButtonListeners(b, cmd, null); } else { b.setVisibility(View.GONE); setButtonEnabled(b, false); b.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null); } }
Example 2
Source File: MonitorFragment.java From onpc with GNU General Public License v3.0 | 6 votes |
@Override public void onMasterVolumeChange(int progressChanged) { // This callback is called when master volume slider is changed. // We shall update the text of the "Audio control" button if (!activity.isConnected()) { return; } final State state = activity.getStateManager().getState(); for (View view : deviceSoundButtons) { if (view instanceof AppCompatButton && audioControlManager.isVolumeLevel(view)) { final AppCompatButton b = (AppCompatButton) view; final String vol = State.getVolumeLevelStr(progressChanged, state.getActiveZoneInfo()); b.setText(vol); } } }
Example 3
Source File: PopupBuilder.java From onpc with GNU General Public License v3.0 | 6 votes |
private AppCompatButton createButton(final AlertDialog alertDialog, final Document document, final Element button, final CustomPopupMsg.UiType uiType) { final AppCompatButton b = new AppCompatButton(context); b.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); b.setGravity(Gravity.CENTER); b.setText(button.getAttribute("text")); b.setOnClickListener(v -> { Utils.showSoftKeyboard(context, v, false); button.setAttribute("selected", "true"); alertDialog.dismiss(); final CustomPopupMsg outMsg = new CustomPopupMsg(uiType, documentToXml(document)); buttonListener.onButtonSelected(outMsg); }); return b; }
Example 4
Source File: BaseFragment.java From onpc with GNU General Public License v3.0 | 6 votes |
AppCompatButton createButton(@StringRes int descriptionId, final ISCPMessage msg, Object tag, final ButtonListener listener) { ContextThemeWrapper wrappedContext = new ContextThemeWrapper(activity, R.style.TextButtonStyle); final AppCompatButton b = new AppCompatButton(wrappedContext, null, 0); final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, buttonSize); lp.setMargins(buttonMarginHorizontal, 0, buttonMarginHorizontal, 0); b.setLayoutParams(lp); b.setText(descriptionId); b.setTag(tag); prepareButtonListeners(b, msg, listener); return b; }
Example 5
Source File: StartActivity.java From Status with Apache License 2.0 | 6 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { AppCompatButton button = new AppCompatButton(inflater.getContext()); button.setText(R.string.optimizations_name); button.setOnClickListener(v -> { if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS) == PackageManager.PERMISSION_GRANTED) { // This intent launches the "evil dialog of misleading and restrictive user freedom", according // to Google Play's policy, but there shouldn't actually be anything wrong with it. The policy // states that this is only acceptable if battery optimization affects the "core functionality" of // the app in question, which... it does. However, it seems their moderators have decided otherwise, // as the update that I pushed containing this intent was taken down. Which is why the permission to use // this intent is now only granted in the OSS product flavor. :( Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); intent.setData(Uri.parse("package:" + getContext().getApplicationContext().getPackageName())); startActivityForResult(intent, REQUEST_OPTIMIZATION); } else { startActivityForResult(new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS), REQUEST_OPTIMIZATION); Toast.makeText(getContext(), R.string.msg_battery_optimizations_switch_enable, Toast.LENGTH_LONG).show(); } }); return button; }
Example 6
Source File: StartActivity.java From Status with Apache License 2.0 | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { AppCompatButton button = new AppCompatButton(inflater.getContext()); button.setText(R.string.action_access_grant); button.setOnClickListener(v -> { startActivityForResult(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS), REQUEST_ACCESSIBILITY); Toast.makeText(getContext(), R.string.msg_notification_switch_enable, Toast.LENGTH_LONG).show(); }); return button; }
Example 7
Source File: StartActivity.java From Status with Apache License 2.0 | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { AppCompatButton button = new AppCompatButton(inflater.getContext()); button.setText(R.string.action_access_grant); button.setOnClickListener(v -> startActivityForResult(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getActivity().getPackageName())), REQUEST_OVERLAY)); return button; }