如何显示“\”在文本视图中
我使用 TypeFace
在应用程序中显示泰米尔字体。这些字母如下 "fe;jr\;b ftrk;"
我将其保存在字符串文件中并尝试在 UI 上检索它。但是 "\"
转义了下一个字符,我错过了一个字符:( 事实上 \ 代表一个字母,我希望显示 \ 。如何做到这一点。
谢谢你提前时间
我的代码如下。
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);
}
}
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);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用两次来转义
\
:"fe;jr\\;b ftrk;"
。这将在字符串中插入一个\
。You need to escape the
\
by using it twice:"fe;j r\\;b ftrk;"
. That will insert a single\
into the string.