当前位置: 首页>>代码示例>>Java>>正文


Java MaterialEditText.addValidator方法代码示例

本文整理汇总了Java中com.rengwuxian.materialedittext.MaterialEditText.addValidator方法的典型用法代码示例。如果您正苦于以下问题:Java MaterialEditText.addValidator方法的具体用法?Java MaterialEditText.addValidator怎么用?Java MaterialEditText.addValidator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.rengwuxian.materialedittext.MaterialEditText的用法示例。


在下文中一共展示了MaterialEditText.addValidator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initValidationEt

import com.rengwuxian.materialedittext.MaterialEditText; //导入方法依赖的package包/类
private void initValidationEt() {
	final MaterialEditText validationEt = (MaterialEditText) findViewById(R.id.validationEt);
   validationEt.addValidator(new RegexpValidator("Only Integer Valid!", "\\d+"));
	final Button validateBt = (Button) findViewById(R.id.validateBt);
	validateBt.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View v) {
       // validate
       validationEt.validate();
     }
   });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:MainActivity.java

示例2: showDialog

import com.rengwuxian.materialedittext.MaterialEditText; //导入方法依赖的package包/类
private void showDialog(DialogType dialogType) {
    View dialogView;
    switch (dialogType) {
        case JOIN_DIALOG:
            dialogView = View.inflate(this, R.layout.dialog_join_party, null);
            break;
        case CREATE_DIALOG:
            dialogView = View.inflate(this, R.layout.dialog_create_party, null);
            break;
        default:
            return;
    }
    Dialog mockDialog = new Dialog(this, R.style.FullScreenDialogStyle);
    mockDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mockDialog.setContentView(dialogView);

    MaterialEditText partyTitle = mockDialog.findViewById(R.id.partyTitle);
    MaterialEditText partyPassword = mockDialog.findViewById(R.id.partyPassword);
    partyTitle.addValidator(new PartyTitleValidator());
    partyPassword.addValidator(new PartyPasswordValidator());

    mockDialog.findViewById(R.id.submitButton).setOnClickListener(c -> {
        switch (dialogType) {
            case JOIN_DIALOG:
                if(!(partyTitle.validate() & partyPassword.validate())) return;
                animateDialog(DialogAction.CLOSE, dialogType, dialogView, mockDialog);
                getPresenter().joinParty(partyTitle.getText().toString(), partyPassword.getText().toString());
                break;
            case CREATE_DIALOG:
                if(!(partyTitle.validate() & partyPassword.validate())) return;
                animateDialog(DialogAction.CLOSE, dialogType, dialogView, mockDialog);
                getPresenter().createParty(partyTitle.getText().toString(), partyPassword.getText().toString());
                break;
        }
    });

    mockDialog.findViewById(R.id.closeDialogButton).setOnClickListener(c ->
        animateDialog(DialogAction.CLOSE, dialogType, dialogView, mockDialog));
    mockDialog.setOnShowListener(dialogInterface ->
        animateDialog(DialogAction.OPEN, dialogType, dialogView, null));
    mockDialog.setOnKeyListener((dialogInterface, i, keyEvent) -> {
        if (i == KeyEvent.KEYCODE_BACK) {
            animateDialog(DialogAction.CLOSE, dialogType, dialogView, mockDialog);
            return true;
        }
        return false;
    });

    mockDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    mockDialog.show();
}
 
开发者ID:ZinoKader,项目名称:SpotiQ,代码行数:52,代码来源:LobbyActivity.java


注:本文中的com.rengwuxian.materialedittext.MaterialEditText.addValidator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。