以编程方式显示TextView的文本

时间:2017-08-04 22:31:57

标签: android textview android-xml

我希望以编程方式设置文本,但出于某种原因,当我这样做时,屏幕上不会显示任何文字。我在下面附上了我的代码。

LayoutInflater inflater =(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View lay = inflater.inflate(R.layout.fs, null);
    lsc = (TextView) lay.findViewById(R.id.fst);
    lsc.setText("XYZ performed on this day.");

有什么想法吗? “fs”是xml文件,它有一个textView组件,其id为“fst”。

0 个答案:

没有答案