Dialog 사용자 정의 쓰기
1518 단어 Dialog 기본 클래스 쓰기
package com.sime.dialog;
import com.sime.R;
import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
/*
* Dialog
* */
public abstract class DefaultDialog extends Builder {
private String[] items;
public DefaultDialog(Activity ac,String[] items,boolean flag) {
super(ac);
this.items=items;
this.items(flag);
}
private void items(boolean flag) {
// TODO Auto-generated method stub
if(flag)
{
this.setPositiveButton(R.string.submit, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
doPositive();
}
});
}
this.setNegativeButton(R.string.conole, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.dismiss();
}});
// !!!!!
this.setItems(items, new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
doItems(which);
}});
}
protected abstract void doPositive();
protected abstract void doItems(int which);
}