package jp.gihyo.mitoma.android.p022widgetstest;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.DialogFragment;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButtonOnClick clickListener = new ButtonOnClick();
        Button btn1 = findViewById(R.id.btRegist);
        btn1.setOnClickListener(clickListener);
        Button btn2 = findViewById(R.id.btUpdate);
        btn2.setOnClickListener(clickListener);
        Button btn3 = findViewById(R.id.btUpdate);
        btn3.setOnClickListener(clickListener);
        Button btn4 = findViewById(R.id.btReturn);
        btn4.setOnClickListener(clickListener);

    }
    private class ButtonOnClick implements View.OnClickListener{
        @Override
        public void onClick(View v) {
            String tag = v.getTag().toString();
            //Toast.makeText(MainActivity.this, "onClick="+tag, Toast.LENGTH_LONG).show();
            switch(tag){
                case "T10":
                    AlertDialogFragment dialog =new AlertDialogFragment();
                    dialog.show(getSupportFragmentManager(),null);
                    break;
                case "T11":
                    //更新処理
                    break;
                case "T12":
                    //削除処理
                    break;
                case "T13":
                    //戻る
                    break;
                default:
                    break;
            }
        }
    }
}


