<file_sep>package com.example.ex02;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {
    EditText text_year;
    TextView text_result;
    Button button_cal;
    String list_first[] = {"Canh", "Tân", "Nhâm", "Quý", "Giáp", "Ât", "Bính", "Đinh", "Mậu", "Kỷ"};
    String list_last[] = {"Thân", "Dậu", "Tuất", "Hợi", "Tý", "Sửu", "Dần", "Mẹo", "Thìn", "Tỵ", "Ngọ", "Mùi"};


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        text_year = findViewById(R.id.text_year);
        text_result = findViewById(R.id.text_result);
        button_cal = findViewById(R.id.button_cal);
        button_cal.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                text_result.setText("");
                if(text_year.getText().toString().trim().length()==0){
                    text_year.requestFocus();
                    return;
                }
                int last_num = Integer.parseInt(text_year.getText().toString().charAt(text_year.getText().toString().length()-1)+"");
                int year = Integer.valueOf(text_year.getText().toString().trim());
                text_result.setText(list_first[last_num]+" "+ list_last[year%12]);
            }
        });

    }
}
<file_sep>package com.example.ex05;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.TextView;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MainActivity extends AppCompatActivity {
    EditText editText_fullname;
    TextView textView_output;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        editText_fullname = findViewById(R.id.editText_fullname);
        textView_output = findViewById(R.id.textView_output);
        editText_fullname.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void afterTextChanged(Editable editable) {
                String fullname = editText_fullname.getText().toString().trim();
                String name[] = fullname.split(" ");
                String temp = "";
                for (int i = 0; i < name.length; i++){
                    if(i!=0){
                        temp += name[i]+" ";
                    }
                }
                textView_output.setText( " Họ : " +name[0] + "\nTên : " + temp);
            }
        });
    }
}
