package jp.gihyo.mitoma.android.s010901basictrans.extra;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import jp.gihyo.mitoma.android.s010901basictrans.R;

public class Activity_B extends AppCompatActivity {
    EditText etValue;
    private static final String TAG = "Activity_B";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_b);
        //遷移元からのデータ受信
        etValue = findViewById(R.id.etValue);
        Intent intent = getIntent();
        String message = intent.getStringExtra("message");
        etValue.setText(message);
        Log.i(TAG,"B Infoテスト");
        Log.d(TAG,"B Debugテスト");
        Button button = findViewById(R.id.button);
        button.setOnClickListener(new ButtonClick());
    }
    private class ButtonClick implements View.OnClickListener{


        public void onClick(View view){
            // Activity_Aに戻る
            String message = etValue.getText().toString();
            Intent intent = new Intent();
            intent.putExtra("message",message);
            setResult(RESULT_OK,intent);
            finish();
        }
    }
}