在DialogFragment

时间:2015-07-24 19:00:57

标签: android validation saripaar

我想在DialogFragment中使用saripaar。

请考虑以下代码:

builder.setView(view);
Dialog dialog = builder.create();
Button register_button = (Button) view.findViewById(R.id.btn_register_send_data);
register_button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        sendData(v);
    }
});
validator = new Validator(this);
validator.setValidationListener(this);

当我想验证时,我得到了这段代码:

java.lang.IllegalStateException: No rules found. You must have at least one rule to validate.如果您使用的是自定义注释 这是我的Xml布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  android:orientation="horizontal"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content">
        <EditText android:layout_width="0dp"
                  android:layout_weight="1"
                  android:layout_height="wrap_content"
                  android:id="@+id/txt_register_name"
                  android:hint="@string/name"
                />
        <EditText android:layout_width="0dp"
                  android:layout_weight="1"
                  android:layout_height="wrap_content"
                  android:id="@+id/txt_register_family"
                  android:hint="@string/family"
                />
    </LinearLayout>
    <EditText android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/txt_register_email"
              android:hint="@string/email"
            />
    <EditText android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/txt_register_password"
              android:hint="@string/password"
              android:gravity="right"
              android:inputType="textPassword"
            />
    <EditText android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/txt_register_confirm_password"
              android:hint="@string/confirm_password"
              android:gravity="right"
              android:inputType="textPassword"
            />
    <Button android:layout_width="match_parent" android:layout_height="wrap_content"
            android:id="@+id/btn_register_send_data" android:text="@string/send_info"/>

我的布局和班级之间有什么关系吗? 我的问题是什么?

0 个答案:

没有答案