2016-04-09 7 views
0

ich die folgende Zeichenfolge haben Tags in meinen strings.xml HTML enthält:Rendering HTML auf Textview funktioniert nicht

<string name="login_title">Ihr Zugang für <br /> <u>zusätzliche</u> <br /> Business Inhalte</string> 

Das Layout:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:maxWidth="686dp" 
    android:orientation="vertical"> 

    <TextView 
     android:id="@+id/login_textview_title" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textColor="@color/textcolorprimary" 
     android:textSize="30sp" 
     android:textStyle="bold" /> 

</LinearLayout> 

Und ich die TextView aufblasen und stellen Sie den Text in einem Dialog:

@NonNull 
@Override 
public Dialog onCreateDialog(Bundle savedInstanceState) { 
    LayoutInflater inflater = this.activity.getLayoutInflater(); 

    AlertDialog.Builder builder = new AlertDialog.Builder(this.activity); 

    View rootView = inflater.inflate(R.layout.dialog_login, null); 

    TextView textViewTitle = (TextView) rootView.findViewById(R.id.login_textview_title); 
    textViewTitle.setText(Html.fromHtml(this.getResources().getString(R.string.login_title))); 

    builder.setView(rootView); 
    builder.setCancelable(false); 

    return builder.create(); 
} 

Und das Ergebnis ist die folgende:

So wird das HTML vollständig ignoriert. Was mache ich falsch?

Antwort

0

Die Lösung gefunden.

Ersetzen Sie alle < innerhalb der Zeichenfolge mit &lt;

Verwandte Themen