我买了书Bill Phillips和Brian Hardy"Android编程大书呆子牧场指南".在第一章中,我使用idea而不是eclipse创建了Gradle解决方案.这个由想法生成的项目不能编译.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new DummyFragment())
.commit();
}
}
Run Code Online (Sandbox Code Playgroud)
XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".QuizActivity$DummyFragment">
<TextView
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud)
错误:找不到符号变量容器
我没有改变任何东西,但项目没有编译
请帮我.
Sha*_*tan 19
正如我在评论中提到的那样,你必须在你的布局中添加以下代码:
android:id = "@+id/container"
Run Code Online (Sandbox Code Playgroud)
您收到该错误,因为您container的xml文件中没有ID
| 归档时间: |
|
| 查看次数: |
20453 次 |
| 最近记录: |