Created
February 5, 2021 15:20
-
-
Save jaeho0613/3685e6043ff1350438578f599828affd to your computer and use it in GitHub Desktop.
Kakao Pay - MainActivity.java
This file contains hidden or 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.jaeho; | |
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; | |
public class MainActivity extends AppCompatActivity { | |
EditText editTextName; | |
EditText editTextPrice; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
editTextName = findViewById(R.id.editName); | |
editTextPrice = findViewById(R.id.editPrice); | |
// 버튼 클릭 이벤트 | |
Button button = findViewById(R.id.buttonPay); | |
button.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
// EditText에 입력한 상품 정보를 가져온다. | |
String name = editTextName.getText().toString(); | |
String price = editTextPrice.getText().toString(); | |
// 결제가 이루어지는 PayActivity를 생성한다. | |
// - 생성자를 이용하여 상품 정보를 입력한다. | |
PayActivity payActivity = new PayActivity(name, price); | |
// Intent로 새로운 Activity를 실행한다. | |
Intent intent = new Intent(getApplicationContext(), payActivity.getClass()); | |
startActivity(intent); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment