Created
June 11, 2020 02:38
-
-
Save godjooyoung/1f228e1f41b043c9b25d4ccd55290ebb to your computer and use it in GitHub Desktop.
화면전환
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.diary; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.Button; | |
import android.widget.Toast; | |
import androidx.appcompat.app.AppCompatActivity; | |
public class WriteActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_write); | |
//4.1. 여기서 Intent를 받아보자. | |
Intent intent = getIntent(); | |
String title = intent.getExtras().getString("title"); | |
Toast.makeText(getApplicationContext(),title, Toast.LENGTH_SHORT).show(); | |
//5.작성완료 버튼에 대한 이벤트를 걸어보자. | |
Button btn2 = findViewById(R.id.btnSave); | |
btn2.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
Intent mainIntent = new Intent(getApplicationContext(), MainActivity.class); | |
mainIntent.putExtra("msg","returnTest"); | |
setResult(RESULT_OK, mainIntent); | |
finish(); | |
} | |
}); | |
}//end of onCreate | |
}//end of class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment