Discussion:
How put "bold" to "android:textStyle" of a TextView from RemoteViews ?
Alix
2009-08-18 16:16:43 UTC
Permalink
Hello,

I have a widget with a TextView. I can change text and color of this
TextView like this :

remoteViews.setTextViewText(R.id.txt, "Sample");
remoteViews.setTextColor(R.id.txt, Color.RED);

But I need to put this TextView "bold" conditionnaly... How can I do
that ?

Thanks in advance...

Alix
Balwinder Kaur (T-Mobile USA)
2009-08-18 17:16:45 UTC
Permalink
TextView.setTypeface(Typeface tf); provided the font you chose
supports "Bold" style.

Balwinder Kaur
Open Source Development Center
·T· · ·Mobile· stick together

The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.
Post by Alix
Hello,
I have a widget with a TextView. I can change text and color of this
remoteViews.setTextViewText(R.id.txt, "Sample");
remoteViews.setTextColor(R.id.txt, Color.RED);
But I need to put this TextView "bold" conditionnaly... How can I do
that ?
Thanks in advance...
Alix
Yusuf Saib (T-Mobile USA)
2009-08-18 17:35:39 UTC
Permalink
Get the TextView object with findViewById() and then call
TextViewsetTypeFace().



Yusuf Saib
Android
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.
Post by Alix
Hello,
I have a widget with a TextView. I can change text and color of this
remoteViews.setTextViewText(R.id.txt, "Sample");
remoteViews.setTextColor(R.id.txt, Color.RED);
But I need to put this TextView "bold" conditionnaly... How can I do
that ?
Thanks in advance...
Alix
Jeff Sharkey
2009-08-19 00:32:13 UTC
Permalink
Because this is across RemoteViews not all TextView methods are
available. In this case, using a SpannableString to mark a bold
region should work, since it's a CharSequence.

j
Post by Alix
Hello,
I have a widget with a TextView. I can change text and color of this
remoteViews.setTextViewText(R.id.txt, "Sample");
remoteViews.setTextColor(R.id.txt, Color.RED);
But I need to put this TextView "bold" conditionnaly... How can I do
that ?
Thanks in advance...
Alix
--
Jeff Sharkey
***@android.com
Alix
2009-08-19 15:55:23 UTC
Permalink
I did the following and it's works !

SpannableString s = new SpannableString("Toto is bold...");
s.setSpan(new StyleSpan(Typeface.BOLD), 0, 4, 0);
remoteViews.setTextViewText(R.id.txt, s);

Thanks

Alix
Post by Jeff Sharkey
Because this is across RemoteViews not all TextView methods are
available.  In this case, using a SpannableString to mark a bold
region should work, since it's a CharSequence.
j
Post by Alix
Hello,
I have a widget with a TextView. I can change text and color of this
remoteViews.setTextViewText(R.id.txt, "Sample");
remoteViews.setTextColor(R.id.txt, Color.RED);
But I need to put this TextView "bold" conditionnaly... How can I do
that ?
Thanks in advance...
Alix
--
Jeff Sharkey
Loading...