我想完成Android Studio文檔中的第一個教程,但我似乎甚至無法做到這一點。Android Studio&Java構建問題
我不斷收到一個:
Error:(17, 60) error: cannot find symbol variable EXTRA_MESSAGE
下面是代碼我DisplayMessageActivity.java
文件:
package com.example.myfirstapp;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.TextView;
public class DisplayMessageActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
ViewGroup layout = (ViewGroup) findViewById(R.id.activity_display_message);
layout.addView(textView);
}
}
我試圖按照教程是在這裏: https://developer.android.com/training/basics/firstapp/starting-activity.html
您是否在'MainActivity'中擁有'public final static String EXTRA_MESSAGE = ...'行,如示例代碼中粗體所示? –
張貼您的主要活動代碼 – sasikumar