• 自定义的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>

  • 相关阅读:
    Luogu P3346 [ZJOI2015]诸神眷顾的幻想乡
    SP10570 LONGCS
    Luogu P3975 [TJOI2015]弦论
    hihocoder #1457 : 后缀自动机四&#183;重复旋律7
    Luogu SP8222 NSUBSTR
    SP7258 SUBLEX
    Luogu P4070 [SDOI2016]生成魔咒
    [清华集训2016]组合数问题
    [NOIP2018TG]保卫王国
    [note]克鲁斯卡尔重构树
  • 原文地址:https://www.cnblogs.com/jeno-song/p/5104605.html
Copyright © 2020-2023  润新知