所以我正在尝试制作一个 Android 应用程序,但是当我尝试编译我的项目时,我得到了错误:
DisplayMessageActivity.java :2 :Error - cannot find symbol
"public class DisplayMessageActivity extends Activity {"
symbol: class Activity
这是我的 DisplayMessageActivity.java 的源代码(它的父级是 MainActivity.java,它导入了 android.app.Activity 和 android.os.Bundle 包):
public class DisplayMessageActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the message from the intent
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
// Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
// Set the text view as the activity layout
setContentView(textView);
}
}
这是 AndroidManifest.xml 文件-
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.HelloWorld"
android:versionCode="1"
android:versionName="1.0">
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher" android:theme="@android:style/Theme.Holo">
<activity android:name="MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".DisplayMessageActivity"
android:label="@string/title_activity_display_message">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android.value="com.example.myfirstapp.MainActivity" />
</activity>
</application>
</manifest>
请帮忙,
Niro56