-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainActivity.java
46 lines (30 loc) · 1.13 KB
/
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
package com.jeberson.message;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
Button button;
String editText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
addListenerOnButton();
}
public void addListenerOnButton() {
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
EditText editText = (EditText) findViewById(R.id.editText);
String text = editText.getText().toString();
Intent myIntent = new Intent(view.getContext(), Main2Activity.class);
myIntent.putExtra("mytext", text);
startActivity(myIntent);
}
});
}
}