自定义的dialog

自定义的dialog  其中包含置顶 删除 和取消   

下面的是BaseDialog 

package com.free.csdn.view.dialog;

import android.app.Dialog;
import android.content.Context;

/**
*
* @author tangqi
* @data 2015年8月8日下午4:26:32
*/

public class BaseDialog extends Dialog {

public BaseDialog(Context context) {
super(context);
}

public BaseDialog(Context context, int theme) {
super(context, theme);
}

/**
* 监听确定
*/
public abstract interface OnConfirmListener {// 抽象的方法 
public abstract void onConfirm(String result);
}

/**
* 监听取消
*/
public abstract interface OnCancleListener {

public abstract void onCancle(String result);
}

/**
* 监听删除
*/
public abstract interface OnDeleteListener {

public abstract void onDelete(String result);
}

/**
* 监听置顶
*/
public abstract interface OnStickListener {

public abstract void onStick(String result);
}

}

 

下面的是得以继承上面的basedialog

package com.free.csdn.view.dialog;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.free.csdn.R;
import com.free.csdn.bean.Blogger;

/**
* 博主相关操作
*
* @author tangqi
* @data 2015年8月8日下午9:54:05
*/

public class BloggerOperationDialog extends BaseDialog implements
android.view.View.OnClickListener {

private OnDeleteListener mOnDeleteListener;
private OnStickListener mOnStickListener;
private Blogger mBlogger;

public BloggerOperationDialog(Context context, Blogger blogger) {
super(context, R.style.Theme_Light_FullScreenDialogAct);//dialog的样式问题
// TODO Auto-generated constructor stub

this.mBlogger = blogger;
setContentView(R.layout.dialog_blogger_operation);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);

TextView deleteView = (TextView) findViewById(R.id.tv_delete_blogger);
TextView stickView = (TextView) findViewById(R.id.tv_stick_blogger);
TextView cacleView = (TextView) findViewById(R.id.tv_cacle_operate);

if (mBlogger.getIsTop() == 0) {
stickView.setText("置顶博主");
} else {
stickView.setText("取消置顶");
}

deleteView.setOnClickListener(this);
stickView.setOnClickListener(this);
cacleView.setOnClickListener(this);
}

@Override
public void onClick(View v) {
dismiss();

switch (v.getId()) {
case R.id.tv_delete_blogger:
mOnDeleteListener.onDelete(null);
break;

case R.id.tv_stick_blogger:
mOnStickListener.onStick(null);
break;

case R.id.tv_cacle_operate:
break;

default:
break;
}
}

/*
* 删除
*/
public void setOnDeleteListener(OnDeleteListener onDeleteListener) {
this.mOnDeleteListener = onDeleteListener;
}

/*
* 置顶
*/
public void setOnStickListener(OnStickListener onStickListener) {
this.mOnStickListener = onStickListener;
}

}

dialog的主题

<style name="Theme.Light.FullScreenDialogAct" parent="@style/BaseDialog">
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowSoftInputMode">adjustPan</item>
</style>

 

你可能感兴趣的:(自定义的dialog)