| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- GitHub 미러링
- 프레시업 #풀무원 #하루한병 #건강만들기 #풀무원 녹즙
- 티스토리 초대장/ 티스토리초대
- GitLab Mirroring
- React Native
- webstorm
- GitHub Mirroring
- 프리티어
- react native #gradle
- 실행시간 측정
- GitLab미러링
- 티스토리 초대장
- settings sync
- gitlab 연동
- Emmet
- Path Alias
- currentTimeMillis
- '티스토리 초대장/ 티스토리초대'
- visual studio code
- code 설치
- 니돈내먹
- 초대장
- 네이버 클라우드 플랫폼
- 티스토리초대
- visual studio code cli
- code 세팅
- eslint-import-resolver-typescript
- 유니옥션
- 음료같은녹즙
- code .
Archives
- Today
- Total
방치하기
dialogbox 리스너 익명클래스 대신 내부클래스 사용 본문
반응형
package com.android.jh;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class DialogExamActivity extends Activity {
private EditText txtMsg;
private Button btnGo;
String msg = "whichbutton";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
txtMsg = (EditText)findViewById(R.id.txtMsg);
btnGo = (Button)findViewById(R.id.btnGo);
btnGo.setOnClickListener(new btnListner());
}
class btnListner implements OnClickListener
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
AlertDialog diaBox = createDialogBox();
diaBox.show();
txtMsg.setText("여기에 대화창 버튼값이 출력됨!");
}
}
AlertDialog createDialogBox()
{
dialogLisnter dialogController = new dialogLisnter();
AlertDialog myQuittingDialogBox=
new AlertDialog.Builder(this).setTitle("대화창 타이틀")
.setMessage("대화창을 나가겠습니까?")
.setPositiveButton("예", dialogController)
.setNeutralButton("취소", dialogController)
.setNegativeButton("아뇨", dialogController)
.create();
return myQuittingDialogBox;
}
class dialogLisnter implements DialogInterface.OnClickListener
{
@Override
public void onClick(DialogInterface dialog, int which) {
if(which == DialogInterface.BUTTON_POSITIVE)
{
msg="whichbutton 예"+which;
txtMsg.setText(msg);
}
else if(which == DialogInterface.BUTTON_NEUTRAL)
{
msg="whichbutton 취소"+which;
txtMsg.setText(msg);
}
else
{
msg="whichbutton 아니오"+which;
txtMsg.setText(msg);
}
}
}
}
반응형
Comments