安卓工作室错误:无法解析符号“查看”
2022-09-01 19:56:32
我正在尝试按照Google的本教程使用Android Studio创建自己的Android应用程序。但是当我按照此页面上的第4步进行操作时:http://developer.android.com/training/basics/firstapp/starting-activity.html Android Studio最终会出现此错误:
Cannot resolve symbol 'View'
这就是我现在的代码:
public class MainActivity extends ActionBarActivity {
/** Called when the user clicks the Send button */
public void sendMessage(View view) { <--- (This line ends up with the error)
// Do something in response to button
}
@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);
}
}
此代码有什么问题?我在Java方面没有经验,在查看了其他问题之后,我仍然找不到正确的解决方案。
感谢您的帮助!