我是一个13岁的男孩,我在udacity中使用android studio进行android开发,并且在大写字母R中存在一个代码问题,我不知道为什么请帮助这个java文件R.java android studio
package com.example.android.courtcounter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
class MainActivity extends AppCompatActivity {
int score = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
/**
* Displays the given score for Team A.
*/
public void displayForTeamA(int score) {
TextView scoreView;
scoreView = (TextView) findViewById(R.team_a_score);this is the problem
scoreView.setText(String.valueOf(score));
}
public void threeScore (int score) {
displayForTeamA(score + 3);
}
public void twoScore (int score) {
displayForTeamA(score + 2);
}
public void freeThrow (int score) {
displayForTeamA(score + 1);
}
}
,这是XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Team A"
android:textSize="16sp"
android:gravity="center_horizontal"
android:padding="4dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0"
android:id="@+id/team_a_score"
android:textSize="16sp"
android:gravity="center_horizontal"
android:padding="4dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="+3 Points"
android:layout_margin="8dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="+2 Points"
android:layout_margin="8dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Free Throw"
android:layout_margin="8dp"/>
</LinearLayout>
,并请一个简单的答案我不是专家:)
线当你问的问题你也不得不说的就是你得到确切的错误错误。它也是编译时间或运行时错误。 –
“@ + id/team_a_score”的'R.id.team_a_score' - 在'R'中有很多不同的东西,它们在不同的类别中。 'R.id','R.string',... – zapl