Question

I'm using TypeFace to show a Tamil font in the app. the letters goes as this "fe;j r\;b ftrk;"

I saved it in the Strings file and trying to retrieve it on the UI. But the "\" escapes the next character and I'm missing a character :( as a matter of fact \ represents a letter and I want \ to be shown. How to do this.

Thanks for your time in advance.

My code is as follows

package com.mayuonline.kanthan;

import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;

public class WelcomeActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Typeface tf = Typeface.createFromAsset(getAssets(), "font/Bamini.ttf");
        TextView TextViewWelcome = (TextView)findViewById(R.id.textViewWelcome);
        TextViewWelcome.setTypeface(tf);
        TextViewWelcome.setText(R.string.WelcomeTitle);
       }
}
Was it helpful?

Solution

You need to escape the \ by using it twice: "fe;j r\\;b ftrk;". That will insert a single \ into the string.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top