How do you print the text to the next activity in Android Studio

Viewed 15

This is on my main activity, after clicking the button it should show the message in the edit text view to the second activity. But for some reason it doesnt show the message I typed in the text view after hitting the button.

public class MainActivity extends AppCompatActivity {
    EditText  edtxt;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        edtxt = (EditText) findViewById(R.id.editTextWord);
    }

    public void btnSend_onClick(View view) {
        String name = edtxt.getText().toString();
        Intent intent = new Intent(this, MainActivity2.class);
        intent.putExtra("Word", name);
        startActivity(intent);

    }
}
0 Answers
Related