List of usage examples for android.widget TextView setContentDescription
@RemotableViewMethod public void setContentDescription(CharSequence contentDescription)
From source file:com.google.android.apps.forscience.whistlepunk.metadata.TriggerHelper.java
public static void populateAutoTextViews(TextView autoTextView, String autoText, int drawableId, Resources res) {/*from w w w . java 2 s. c o m*/ autoTextView.setText(autoText); autoTextView .setContentDescription(res.getString(R.string.trigger_label_icon_content_description, autoText)); Drawable drawable = res.getDrawable(drawableId); DrawableCompat.setTint(drawable.mutate(), res.getColor(R.color.text_color_light_grey)); autoTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(drawable, null, null, null); }
From source file:com.ofalvai.bpinfo.util.UiUtils.java
/** * Adds a rectangular icon for the affected route. * * First it creates a TextView, then sets the style properties of the view. * The custom colored rounded background is achieved by a Drawable and a ColorFilter on top of that. *//* w ww . jav a 2 s .c o m*/ public static void addRouteIcon(Context context, @NonNull ViewGroup root, @NonNull Route route) { ContextThemeWrapper iconContextTheme = new ContextThemeWrapper(context, R.style.RouteIcon); TextView iconView = new TextView(iconContextTheme); iconView.setText(route.getShortName()); iconView.setTextColor(route.getTextColor()); iconView.setContentDescription(Utils.getContentDescriptionForRoute(context, route)); root.addView(iconView); // Layout attributes defined in R.style.RouteIcon were ignored before attaching the view to // a parent, so we need to manually set them ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) iconView.getLayoutParams(); params.width = ViewGroup.LayoutParams.WRAP_CONTENT; int margin = (int) context.getResources().getDimension(R.dimen.route_icon_margin); params.rightMargin = margin; params.topMargin = margin; // A requestLayout() call is not necessary here because the setBackground() method below // will call that anyway. //iconView.requestLayout(); // Setting a custom colored rounded background drawable as background Drawable iconBackground = context.getResources().getDrawable(R.drawable.rounded_corner_5dp); if (iconBackground != null) { ColorFilter colorFilter = new LightingColorFilter(Color.rgb(1, 1, 1), route.getColor()); iconBackground.mutate().setColorFilter(colorFilter); iconView.setBackground(iconBackground); } }
From source file:com.stasbar.knowyourself.Utils.java
/** * Clock views can call this to refresh their alarm to the next upcoming value. *///from w w w . j a v a2s . co m public static void refreshAlarm(Context context, View clock) { final TextView nextAlarmIconView = (TextView) clock.findViewById(R.id.nextAlarmIcon); final TextView nextAlarmView = (TextView) clock.findViewById(R.id.nextAlarm); if (nextAlarmView == null) { return; } final String alarm = getNextAlarm(context); if (!TextUtils.isEmpty(alarm)) { final String description = context.getString(R.string.next_alarm_description, alarm); nextAlarmView.setText(alarm); nextAlarmView.setContentDescription(description); nextAlarmView.setVisibility(View.VISIBLE); nextAlarmIconView.setVisibility(View.VISIBLE); nextAlarmIconView.setContentDescription(description); nextAlarmIconView.setTypeface(UiDataModel.getUiDataModel().getAlarmIconTypeface()); } else { nextAlarmView.setVisibility(View.GONE); nextAlarmIconView.setVisibility(View.GONE); } }
From source file:com.androidinspain.deskclock.Utils.java
/** * Clock views can call this to refresh their alarm to the next upcoming value. *///from w w w.j a v a 2 s. c o m public static void refreshAlarm(Context context, View clock) { final TextView nextAlarmIconView = (TextView) clock.findViewById(R.id.nextAlarmIcon); final TextView nextAlarmView = (TextView) clock.findViewById(R.id.nextAlarm); if (nextAlarmView == null) { return; } final String alarm = getNextAlarm(context); if (!TextUtils.isEmpty(alarm)) { final String description = context.getString(R.string.next_alarm_description, alarm); nextAlarmView.setText(alarm); nextAlarmView.setContentDescription(description); nextAlarmView.setVisibility(View.VISIBLE); nextAlarmIconView.setVisibility(View.VISIBLE); nextAlarmIconView.setContentDescription(description); } else { nextAlarmView.setVisibility(View.GONE); nextAlarmIconView.setVisibility(View.GONE); } }
From source file:com.wizardsofm.deskclock.Utils.java
/** * Clock views can call this to refresh their alarm to the next upcoming value. *//* w w w . j a v a 2s . co m*/ public static void refreshAlarm(Context context, View clock) { final TextView nextAlarmIconView = (TextView) clock .findViewById(com.wizardsofm.deskclock.R.id.nextAlarmIcon); final TextView nextAlarmView = (TextView) clock.findViewById(com.wizardsofm.deskclock.R.id.nextAlarm); if (nextAlarmView == null) { return; } final String alarm = getNextAlarm(context); if (!TextUtils.isEmpty(alarm)) { final String description = context.getString(com.wizardsofm.deskclock.R.string.next_alarm_description, alarm); nextAlarmView.setText(alarm); nextAlarmView.setContentDescription(description); nextAlarmView.setVisibility(View.VISIBLE); nextAlarmIconView.setVisibility(View.VISIBLE); nextAlarmIconView.setContentDescription(description); nextAlarmIconView.setTypeface(UiDataModel.getUiDataModel().getAlarmIconTypeface()); } else { nextAlarmView.setVisibility(View.GONE); nextAlarmIconView.setVisibility(View.GONE); } }
From source file:com.android.deskclock.Utils.java
/** Clock views can call this to refresh their alarm to the next upcoming value. */ public static void refreshAlarm(Context context, View clock) { final TextView nextAlarmView = (TextView) clock.findViewById(R.id.nextAlarm); if (nextAlarmView == null) { return;//from w w w . j a v a 2 s . c o m } final String alarm = getNextAlarm(context); if (!TextUtils.isEmpty(alarm)) { final String description = context.getString(R.string.next_alarm_description, alarm); nextAlarmView.setText(alarm); nextAlarmView.setContentDescription(description); nextAlarmView.setVisibility(View.VISIBLE); } else { nextAlarmView.setVisibility(View.GONE); } }
From source file:com.wizardsofm.deskclock.Utils.java
/** * Clock views can call this to refresh their date. **//* w ww .j av a2 s . co m*/ public static void updateDate(String dateSkeleton, String descriptionSkeleton, View clock) { final TextView dateDisplay = (TextView) clock.findViewById(com.wizardsofm.deskclock.R.id.date); if (dateDisplay == null) { return; } final Locale l = Locale.getDefault(); final String datePattern = DateFormat.getBestDateTimePattern(l, dateSkeleton); final String descriptionPattern = DateFormat.getBestDateTimePattern(l, descriptionSkeleton); final Date now = new Date(); dateDisplay.setText(new SimpleDateFormat(datePattern, l).format(now)); dateDisplay.setVisibility(View.VISIBLE); dateDisplay.setContentDescription(new SimpleDateFormat(descriptionPattern, l).format(now)); }
From source file:com.fbartnitzek.tasteemall.addentry.CompletionUserAdapter.java
@Override public void setViewText(TextView v, String text) { switch (v.getId()) { case R.id.list_item_user_name: v.setText(text);//from www .j a v a 2 s . c o m v.setContentDescription(mActivity.getString(R.string.a11y_user_name, text)); break; default: super.setViewText(v, text); } }
From source file:org.iisgcp.waterwalk.utils.LicenseDialog.java
@Override public void onStart() { super.onStart(); // Make the textview clickable. Must be called after show() TextView message = (TextView) mDialog.findViewById(android.R.id.message); message.setMovementMethod(LinkMovementMethod.getInstance()); message.setContentDescription(Html.fromHtml(mDialogText).toString()); }
From source file:com.android.deskclock.Utils.java
/** Clock views can call this to refresh their date. **/ public static void updateDate(String dateSkeleton, String descriptionSkeleton, View clock) { final TextView dateDisplay = (TextView) clock.findViewById(R.id.date); if (dateDisplay == null) { return;//from w w w. j a v a2s . c om } final Locale l = Locale.getDefault(); final String datePattern = DateFormat.getBestDateTimePattern(l, dateSkeleton); final String descriptionPattern = DateFormat.getBestDateTimePattern(l, descriptionSkeleton); final Date now = new Date(); dateDisplay.setText(new SimpleDateFormat(datePattern, l).format(now)); dateDisplay.setVisibility(View.VISIBLE); dateDisplay.setContentDescription(new SimpleDateFormat(descriptionPattern, l).format(now)); }