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);
}

좋은 웹페이지 즐겨찾기