[英]TextView setText Cannot resolve type
Im using Android Studio, trying set text to Text View but every time i do this 我正在使用Android Studio,尝试将文本设置为``文本视图'',但是每次我这样做
TextView test = (TextView) findViewById(R.id.testView);
test.setText("fds");
on Android Studio i see Cannot resolve symbol 'setText'
. 在Android Studio上,我看到
Cannot resolve symbol 'setText'
。 Can someone tell me what im doing wrong? 有人可以告诉我我做错了什么吗?
setText()
will accept String which you have passed, so there is no issue in that. setText()
将接受您已传递的String,因此没有问题。
One possible reason for this might be you have not written your code inside onCreate()
or onCreateView()
. 造成这种情况的一种可能原因是您没有在
onCreate()
或onCreateView()
编写代码。
Activity
you need to use these lines after setContentView()
in onCreate()
. Activity
,则需要在onCreate()
setContentView()
之后使用这些行。 Fragment
you need to use these lines after inflating your view
in onCreateView()
. Fragment
,则需要在onCreateView()
扩大view
后使用这些行。 Second reason, you might be having one more test
variable of different type like String or something else 第二个原因,您可能还有另一个不同类型的
test
变量,例如String或其他
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.