Displaying the error message in android edittext on the right side when using validation instead of on the below edit text -


this question has answer here:

public class mainactivity extends activity { private edittext emailedittext; private edittext passedittext;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      emailedittext = (edittext) findviewbyid(r.id.edittext_email);     passedittext = (edittext) findviewbyid(r.id.edittext_password);      findviewbyid(r.id.btn_signup).setonclicklistener(new onclicklistener() {          @override         public void onclick(view arg0) {              final string email = emailedittext.gettext().tostring();             if (!isvalidemail(email)) {                 emailedittext.seterror("invalid email");              }              final string pass = passedittext.gettext().tostring();             if (!isvalidpassword(pass)) {                 passedittext.seterror("invalid password");             }          }     }); } 

i using code shows error message below, want display message adjacent edittext i.e; right of edittext.

instead of using edittext use textinputlayout like:

<android.support.design.widget.textinputlayout     android:id="@+id/text_input_layout"     android:layout_width="match_parent"     android:layout_height="wrap_content"     app:errorenabled="true">      <android.support.design.widget.textinputedittext         android:id="@+id/edit_text"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:hint="enter name" />  </android.support.design.widget.textinputlayout> 

when want seterror take reference of textinputlayout , seterror on , when error resolved remove passin null in seterror


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -