Android Studio error: cannot find symbol class intent
本问题已经有最佳答案,请猛点这里访问。
我一直在遵循谷歌的指南(https://developer.android.com/training/basics/first app/starting-activity.html)制作我的第一个应用程序,并得到以下错误:错误:(48,29)错误:找不到符号类意图因为我对Java不太了解,现在我不知道该怎么办,所以请人帮帮我吧!
下面是mainactivity.java的代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | package com.mycompany.myfirstapp; import android.content.Intent; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.content.Intent; import android.view.View; import android.widget.EditText; public class MainActivity extends ActionBarActivity { public final static String EXTRA_MESSAGE ="com.mycompany.myfirstapp.MESSAGE"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } /**Called when the user clicks the Send button*/ public void sendMessage(View view) { // Do something in response to button Intent intent = new intent(this, DisplayMessageActivity.class); EditText editText = (EditText) findViewById(R.id.edit_message); String message = editText.getText().toString(); intent.putExtra(EXTRA_MESSAGE, message); startActivity(intent); } } |
这是正确的声明
在着手Android开发之前,你应该先复习一下Java概念。在Java中,意图和意图被认为是两种不同的事物。