'cannot find symbol ActionBarActivity' following Android Development Tutorial?

前端 未结 2 1942
名媛妹妹
名媛妹妹 2021-01-15 05:43

So I am following this tutorial, using Sublime as a text editor and compiling everything from console.

All was working good, but when we came to the part where you

2条回答
  •  走了就别回头了
    2021-01-15 05:52

    It really helped much until I got a successful build. They also confused me with the MainActivity sometimes referring to MyActivity. So anyway the DisplayMessageActivity.java file looks as above and for a successful I had the MyActivity.java code as below:

    package com.example.myfirstapp;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.content.Intent;
    import android.view.View;
    import android.widget.EditText;
    
    public class MyActivity extends Activity {
    
    //public class MyActivity extends ActionBarActivity {
    public final static String EXTRA_MESSAGE = "com.mycompany.myfirstapp.MESSAGE";
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
         super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
    
    /** Called when the user clicks the Send button */  
    public void sendMessage(View view) {
    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);
    }
    }
    

    And now I can run my apk :-)

提交回复
热议问题