-
Notifications
You must be signed in to change notification settings - Fork 52
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Element validation #66
Comments
Which class does your custom element inherit? If it's |
Hai,
Below code is the Custom Element
package com.tt.uloor.utils;
import android.content.Context;
import android.support.design.widget.TextInputLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import com.github.dkharrat.nexusdialog.controllers.LabeledFieldController;
import com.tt.uloor.R;
import com.tt.uloor.api.response.ShopDetailResponse;
public class CustomEditTextElement extends LabeledFieldController {
private final String mHint;
private final ShopDetailResponse.Result element;
private Context mCtx;
public CustomEditTextElement(Context ctx, String name, String
textPlaceholder, ShopDetailResponse.Result element) {
super(ctx, name, null, false);
mCtx = ctx;
mHint = textPlaceholder;
this.element = element;
}
@OverRide
protected View createFieldView() {
LayoutInflater inflater = (LayoutInflater)
mCtx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.custom_edittext_element, null);
TextInputLayout textInputLayout = (TextInputLayout)
view.findViewById(R.id.value_layout);
textInputLayout.setHint(mHint);
return view;
}
public ShopDetailResponse.Result getValue() {
return element;
}
public EditText getEditText() {
return (EditText) getView().findViewById(R.id.value);
}
public TextInputLayout getInputLayout() {
return (TextInputLayout) getView().findViewById(R.id.value_layout);
}
public void refresh() {
// nothing to refresh
}
}
|
Below code is the XML layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:id="@+id/value_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
<EditText
android:id="@+id/value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
…On Sun, Sep 17, 2017 at 8:07 PM, karthik kumar ***@***.***> wrote:
Hai,
Below code is the Custom Element
package com.tt.uloor.utils;
import android.content.Context;
import android.support.design.widget.TextInputLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import com.github.dkharrat.nexusdialog.controllers.LabeledFieldController;
import com.tt.uloor.R;
import com.tt.uloor.api.response.ShopDetailResponse;
public class CustomEditTextElement extends LabeledFieldController {
private final String mHint;
private final ShopDetailResponse.Result element;
private Context mCtx;
public CustomEditTextElement(Context ctx, String name, String textPlaceholder, ShopDetailResponse.Result element) {
super(ctx, name, null, false);
mCtx = ctx;
mHint = textPlaceholder;
this.element = element;
}
@OverRide
protected View createFieldView() {
LayoutInflater inflater = (LayoutInflater) mCtx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.custom_edittext_element, null);
TextInputLayout textInputLayout = (TextInputLayout) view.findViewById(R.id.value_layout);
textInputLayout.setHint(mHint);
return view;
}
public ShopDetailResponse.Result getValue() {
return element;
}
public EditText getEditText() {
return (EditText) getView().findViewById(R.id.value);
}
public TextInputLayout getInputLayout() {
return (TextInputLayout) getView().findViewById(R.id.value_layout);
}
public void refresh() {
// nothing to refresh
}
}
|
In this case, pass a set of validators to the public CustomEditTextElement(Context ctx, String name, String textPlaceholder, ShopDetailResponse.Result element, Set<InputValidator> validators) {
super(ctx, name, null, validators);
mCtx = ctx;
mHint = textPlaceholder;
this.element = element;
} For an example, on how to pass validators, see the 'samples' project included in the repo. |
Thank you so much for your solution for the problem.
…On Sun, Sep 17, 2017 at 10:49 PM, Dia Kharrat ***@***.***> wrote:
Closed #66 <#66>.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#66 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AGTDrFWVzANvV6JIeaTXyH5LkYEDs0gPks5sjVSPgaJpZM4PSPfU>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can i set filed required validator for My custom element which is created by ownself.
Kindly let me know, thanks in advance
The text was updated successfully, but these errors were encountered: