android - 关于主要 Activity : 'illegal start of expres

我正在尝试构建一个简单的应用程序,如果用户输入文本消息并单击一个按钮,则该消息将显示在下一个 View 中。

它曾经可以正常工作,但是后来我添加了几行代码,并将其删除了,现在它不再像以前那样工作了。

编译器不会运行我的代码,并继续说“非法的表达开始”和“;预期'。

如果有人可以在这里帮助我,我将不胜感激。
这是我的代码:

public class MainActivity extends ActionBarActivity {
    public final static String EXTRA_MESSAGE = "com.yhmac.myapplication3.MESSAGE";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);


        /** Called when the user clicks the Send button */

    public void sendMessage(View view) {
        // Do something in response to button
        Intent intent = new Intent(this, IntroToApp.class);
        EditText editText = (EditText) findViewById(R.id.edit_message);
        String message = editText.getText().toString();
        intent.putExtra(EXTRA_MESSAGE, message);
        startActivity(intent);
    }
}

最佳答案

请关闭您的onCreate方法。

public class MainActivity extends ActionBarActivity {
    public final static String EXTRA_MESSAGE = "com.yhmac.myapplication3.MESSAGE";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }



        /** Called when the user clicks the Send button */

    public void sendMessage(View view) {
        // Do something in response to button
        Intent intent = new Intent(this, IntroToApp.class);
        EditText editText = (EditText) findViewById(R.id.edit_message);
        String message = editText.getText().toString();
        intent.putExtra(EXTRA_MESSAGE, message);
        startActivity(intent);
    }
   }

关于android - 关于主要 Activity : 'illegal start of expression' 的错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27602133/

相关文章:

compilation - 如何在Windows上的SCons中导出具有备用扩展名的程序

c# - 如何从 C# 中的封闭构造类中获取基类对象

c# - 抑制ASPX文件的生成错误

compiler-errors - 如何解决MiniZinc错误: “model inconsist

actionscript-3 - 如果使用 Flash Builder 4.7 而不是 4.6,则基

android - Android Delphi xe7中的错误

caching - 如何处理并发Web用户的重置CS-Script

actionscript-3 - for(const i)而不是(var i)

objective-c - 隐式转换为NSIndexPath的错误

compiler-errors - Latex中缺少\begin {document}