smiling1990

博客园 首页 联系 订阅 管理
MaterialDialog的用法:

/**
*
* @author smiling
* @date 2016/10
*/

Github:https://github.com/drakeet/MaterialDialog

Android Studio 导包:

compile 'me.drakeet.materialdialog:library:1.3.1'

程序:

MaterialDialog mMaterialDialog = new MaterialDialog(this)
  .setTitle("MaterialDialog")
  .setMessage("Hello world!")
  .setPositiveButton("OK", new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      mMaterialDialog.dismiss();
      ...
    }
  })
  .setNegativeButton("CANCEL", new View.OnClickListener() {
  @Override
  public void onClick(View v) {
      mMaterialDialog.dismiss();
      ...
    }
  });

mMaterialDialog.show();

//在展示之前,可以随时更改消息
mMaterialDialog.setTitle("提示");
mMaterialDialog.show();
//显示后,也可以随时更改消息
mMaterialDialog.setMessage("你好,世界~");

setView (View v) & setContentView():

EditText contentView = new EditText(this);
MaterialDialog mMaterialDialog = new MaterialDialog(this).setView(contentView);

mMaterialDialog.show();

setBackgroundResource(int resId) or setBackground(Drawable drawable):

mMaterialDialog.setBackgroundResource(R.drawable.background);

posted on 2016-10-14 09:04  smiling1990  阅读(2185)  评论(0编辑  收藏  举报