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