當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。