setText()不起作用 [英] setText() not working

查看:79
本文介绍了setText()不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

setText(),setTextsize()和addView无法正常工作.显示为无法解析符号类型.

setText(), setTextsize() and addView is not working. It is shown as cannot resolve symbol type.

Intent intent = getIntent();
String message = intent.getStringExtra(MyActivity.EXTRA_MESSAGE);
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);

RelativeLayout layout = (RelativeLayout) findViewById(R.id.content);
layout.addView(textView);

推荐答案

在放大版式之前,您不能使用 add 通过ID查找视图之类的方法.验证之前是否调用过setContentView.

You can't use methods such as add and find view by id before the layout is inflated. Verifý that setContentView is called before.

如果是,请用日志查看 message 的值.

If it does, look at the value of message with a log.

这篇关于setText()不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆