-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainActivity.java
36 lines (29 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
package com.example.anany.edittextsandmultipleactivities;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
EditText et;
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et = findViewById(R.id.edit);
btn = findViewById(R.id.btn);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(et.getText().toString().isEmpty() || et.getText().toString()==null){
Toast.makeText(getApplicationContext(), "No text entered", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), et.getText().toString(), Toast.LENGTH_LONG).show();
}
}
});
}
}