1

I am creating a list using recyclerview. I am using weathericons for textview.

The problem is, if I use the font in BindViewHolder as:

  @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        holder.textViewSicon.setText(Html.fromHtml("&#xf051"));
    }

its working fine, i.e. the intended font is properly displayed. But, I want to use it from array list itself, as: in adapter

@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
  holder.textViewSicon.setText(sunSession.getSicon());

where the getSicon is defined as:

  public String getSicon() {
    return sicon;
  }

and finally I am populating the list as:

sunsList.add(
    new SunSession(
       "&#xf047"
 }

which is not giving me the proper font.

I have also defined the layout as

<TextView
    android:fontFamily="@font/weathericons"
    android:gravity="center|clip_vertical|clip_horizontal"
    android:text="@string/sunrise"
    android:textAlignment="center">
</TextView>
BaRud
  • 3,055
  • 7
  • 41
  • 89
  • https://stackoverflow.com/a/46639282/7666442 – AskNilesh Mar 12 '18 at 04:14
  • if you downloaded the font, you need to place it in asset folders first and then do the reference programatically in order to use it, maybe in your layout you will not be able to see it but when you run the code you will be able to see the font – Gastón Saillén Mar 12 '18 at 04:14
  • I have checked that before, but the problem is the font is only working from adapter. If i change the font in adapter, then its working. But not from the array. So, in a sense, those values are bind to adapter and not the real array. any idea? – BaRud Mar 12 '18 at 04:31

0 Answers0