Java Code Examples for androidx.appcompat.app.AppCompatActivity#getString()
The following examples show how to use
androidx.appcompat.app.AppCompatActivity#getString() .
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: PlayingQueueAdapter.java From VinylMusicPlayer with GNU General Public License v3.0 | 5 votes |
public static void initializeSnackBar(final PlayingQueueAdapter adapter,final int position, final AppCompatActivity activity, final boolean isPlayingSongToRemove) { CharSequence snackBarTitle = activity.getString(R.string.snack_bar_title_removed_song); Snackbar snackbar = Snackbar.make(activity.findViewById(R.id.content_container), snackBarTitle, Snackbar.LENGTH_LONG); TextView songTitle = snackbar.getView().findViewById(R.id.snackbar_text); songTitle.setSingleLine(); songTitle.setEllipsize(TextUtils.TruncateAt.END); songTitle.setText(adapter.dataSet.get(position).title + " " + snackBarTitle); snackbar.setAction(R.string.snack_bar_action_undo, v -> { MusicPlayerRemote.addSong(position,adapter.getSongToRemove()); //If playing and currently playing song is removed, then added back, then play it at //current song progress if (isPlayingSongToRemove) { MusicPlayerRemote.playSongAt(position); } }); snackbar.setActionTextColor(getBackgroundColor(activity)); snackbar.show(); //Fixes Snackbar not showing when it replaces another Snackbar //See: https://stackoverflow.com/questions/43680655/snackbar-sometimes-doesnt-show-up-when-it-replaces-another-one currentlyShownSnackbar = snackbar; }
Example 2
Source File: AppBarLayoutBaseTest.java From material-components-android with Apache License 2.0 | 5 votes |
@CallSuper protected void configureContent(@LayoutRes final int layoutResId, @StringRes final int titleResId) throws Throwable { TextAppearanceConfig.setShouldLoadFontSynchronously(true); onView(withId(R.id.coordinator_stub)).perform(inflateViewStub(layoutResId)); mAppBar = mCoordinatorLayout.findViewById(R.id.app_bar); mCollapsingToolbar = mAppBar.findViewById(R.id.collapsing_app_bar); mToolbar = mAppBar.findViewById(R.id.toolbar); final AppCompatActivity activity = activityTestRule.getActivity(); activityTestRule.runOnUiThread(() -> activity.setSupportActionBar(mToolbar)); final CharSequence activityTitle = activity.getString(titleResId); activityTestRule.runOnUiThread(() -> activity.setTitle(activityTitle)); getInstrumentation().waitForIdleSync(); if (mCollapsingToolbar != null) { onView(withId(R.id.collapsing_app_bar)) .perform(setTitle(activityTitle)) .perform(setContentScrimColor(Color.MAGENTA)); } TextView dialog = mCoordinatorLayout.findViewById(R.id.textview_dialogue); if (dialog != null) { onView(withId(R.id.textview_dialogue)) .perform(setText(TextUtils.concat(Shakespeare.DIALOGUE))); } mDefaultElevationValue = mAppBar.getResources().getDimension(R.dimen.design_appbar_elevation); }
Example 3
Source File: PlotFunction.java From microMathematics with GNU General Public License v3.0 | 4 votes |
@Override public void onDetails(View owner) { if (!enableDetails()) { return; } final ArrayList<FunctionIf> functions = functionView.getFunctions(); if (functions.size() == 1) { showDetailsDialog(0); } else { final AppCompatActivity ctx = getFormulaList().getActivity(); final DialogRadioGroup d = new DialogRadioGroup(ctx, R.string.dialog_function_selection, functions.size(), new DialogRadioGroup.EventHandler() { public void onCreate(RadioButton[] rb) { for (int i = 0; i < rb.length; i++) { final String text = ctx.getString(R.string.dialog_function_selection) + " " + Integer.toString(i + 1) + ":"; rb[i].setText(text); final Paint p = functions.get(i).getLineParameters().getPaint(); final int textWidth = (int) rb[i].getPaint().measureText(text); rb[i].setCompoundDrawables(null, null, new LineDrawable(p, textWidth, (int) (p.getStrokeWidth() + 4)), null); rb[i].setCompoundDrawablePadding(ctx.getResources().getDimensionPixelSize( R.dimen.dialog_content_padding)); } } public void onClick(int whichButton) { showDetailsDialog(whichButton); } }); d.show(); } }