我有一个错误:
R cannot be resolved to a variable
Run Code Online (Sandbox Code Playgroud)
排队:
setContentView(R.layout.main);
Run Code Online (Sandbox Code Playgroud)
但我不能解决它做其他用户写的东西应该尝试,这是:
layout main.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助!
小智 1
是的,我被困在这个问题上好几个小时了。我的解决方案是:从工作区中删除所有项目->通过转到文件->导入->浏览->选择项目->重新导入所需的项目->最后选中“将项目添加到工作集框”,然后单击完成。我曾经的 .R 错误消失了。我希望这可以帮助别人!