我一直在試圖在Youtube上關注教程視頻。當我嘗試在模擬器中查看它時,他會在他的視頻中看到以下錯誤。如何解決「錯誤:';'預計「Android Studio中的錯誤?
Error:(22, 48) error: ';' expected
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
我已經做了一個快速的網絡搜索,並且人們建議檢查JDK文件的位置。我已經做到了這一點,但沒有幫助。這是我的JDK位置。
C:\Program Files\Java\jdk1.8.0_121
這是我從教程中複製的一小段代碼。
package shmaves.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.RelativeLayout;
import android.widget.Button;
import android.graphics.Color;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//layout
RelativeLayout shmavesLayout = new RelativeLayout(this);
shmavesLayout.setBackgroundColor(Color.GREEN);
//Button
Button redButton = new Button (this);
redButton.setText ("click me");
redButton.setBackgroundColor(Color.RED)
//Add widget to layout (button is now a child of layout
shmavesLayout.addView(redButton);
//Set this activities content/display to this view
setContentView(shmavesLayout);
}
}
任何人都可以擺脫一些光線或看看我哪裏出了錯?我對這一切都很陌生,所以請詳細解釋。
這工作。謝謝!我不知道這是什麼意思。 – Shmaves