Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- #ifdef
- DB 데이터
- 환경변수 설정
- flask
- #endif
- Action
- Django
- bootstrap4 패키지
- 튜토리얼
- javascript
- bootstrap
- MySQL 세팅
- #ifndef
- PyQt5
- #undef
- 실시간 시계
- #if
- 사이트 도메인
- href
- openweathermap
- OpenCV
- 성능지표
- VS Code
- jinja2
- heroku
- DB 데이터 저장
- OpenCV + Flask
- #else
- 콘솔 가상환경 # 콘솔 #가상환경
- 명령어
Archives
- Today
- Total
PROGRAMMING
AlertDialog 본문
※ 참고(alert dialog, 로그인 dialog) webnautes.tistory.com/1094
안드로이드 개념 및 예제 - AlertDialog
다이얼로그(dialog)는 전체 화면을 다 채우지 않고 일부 화면만 가리는 윈도우로, 사용자가 예/아니오 같은 선택을 하거나 추가적인 정보 입력을 하기를 기다립니다. 사용자가 응답하기 전까지
webnautes.tistory.com
package com.example.a201030_6;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onBtnAlert(View view) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setMessage("결제하시겠습니까?");
alertDialogBuilder.setPositiveButton("yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "결제가 완료되었습니다.", Toast.LENGTH_SHORT).show();
}
});
alertDialogBuilder.setNeutralButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "결제가 취소되었습니다.", Toast.LENGTH_SHORT).show();
finish();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<Button
android:id="@+id/btn_alert"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onBtnAlert"
android:text="결제하려면 버튼을 누르세요." />
</LinearLayout>
'Android' 카테고리의 다른 글
어플 접속화면(feat. 이상형월드컵) (0) | 2020.10.30 |
---|---|
이상형월드컵(ver. teacher) (0) | 2020.10.30 |
PopUp (0) | 2020.10.30 |
Custom Dialog (로그인) (0) | 2020.10.30 |
ActionBar (0) | 2020.10.30 |
Comments