2017-07-22 1 views
0

Il y a ce problème que mon code fonctionne réellement, mais j'ai mis quelques textes à montrer quand le texte d'édition est vide. et quand j'appuie sur le bouton de connexion, mon application se bloque. et voici l'erreur:Erreur de gonflement de la classe textview dans android

android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class TextView Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class TextView Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 4: TypedValue{t=0x2/d=0x1010099 a=1}

ici est mon code xml:

<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingTop="56dp" 
    android:paddingLeft="24dp" 
    android:paddingRight="24dp"> 

<ImageView android:src="@drawable/logo" 
    android:layout_width="wrap_content" 
    android:layout_height="72dp" 
    android:layout_marginBottom="24dp" 
    android:layout_gravity="center_horizontal" /> 


<android.support.design.widget.TextInputLayout 
    android:layout_width="match_parent" 
    android:id="@+id/input_username_id" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="8dp" 
    android:theme="@style/TextLabel" 
    android:layout_marginBottom="20dp"> 

    <EditText 
     android:id="@+id/input_email" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textColor="@color/white" 
     android:textColorHint="@color/white" 
     android:hint="@string/hint_username" 
     android:inputType="textEmailAddress" 
     android:layout_marginRight="10dp" 
     android:gravity="right" /> 
</android.support.design.widget.TextInputLayout> 

<android.support.design.widget.TextInputLayout 
    android:id="@+id/input_password_id" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="8dp" 
    android:layout_marginBottom="20dp" 
    android:theme="@style/TextLabel"> 

    <EditText 
     android:id="@+id/input_password" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="right" 
     android:textColor="@color/white" 
     android:textColorHint="@color/white" 
     android:hint="@string/hint_password" 
     android:inputType="textPassword" /> 
</android.support.design.widget.TextInputLayout> 

<android.support.v7.widget.AppCompatButton 
    android:id="@+id/btn_login" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="35dp" 
    android:layout_marginBottom="40dp" 
    android:padding="12dp" 
    android:paddingLeft="30dp" 
    android:background="@drawable/my_button" 
    android:drawableLeft="@drawable/ic_stat_login" 
    android:textColor="@color/white" 
    android:text="ورود"/> 
<TextView android:id="@+id/link_signup" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:layout_marginBottom="24dp" 
    android:layout_marginTop="10dp" 
    android:textColor="@color/white" 
    android:text="create an account" 
    android:gravity="center" 
    android:textSize="13dp" 
    /> 
<TextView android:id="@+id/link_forgetpass" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:layout_marginBottom="24dp" 
    android:layout_marginTop="10dp" 
    android:textColor="@color/white" 
    android:text="forget my password" 
    android:gravity="center" 
    android:textSize="13dp" 
    /> 
</LinearLayout> 

Voici mon code java:

_emailText = (EditText) (findViewById(R.id.input_email)); 
_passwordText = (EditText) (findViewById(R.id.input_password)); 
_loginButton = (Button) (findViewById(R.id.btn_login)); 

_loginButton.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       login(); 
      } 
}); 
public void login() { 
    Log.d(TAG, "Login"); 
    if (!validate()) { 
     onLoginFailed(); 
     return; 
    } 
    email = _emailText.getText().toString(); 
    String password = _passwordText.getText().toString(); 

    JsonObject json = new JsonObject(); 
    json.addProperty("email", email); 
    json.addProperty("password", password); 

    _loginButton.setEnabled(false); 
    WebService.connect(LoginActivity.this, json, "login",layout_for_progressbar); 
} 
public boolean validate() { 
    boolean valid = true; 
    String email = _emailText.getText().toString(); 
    String password = _passwordText.getText().toString(); 

    if (email.isEmpty() || !android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches()) { 
     _emailText.setError("Wrong Email"); 
     valid = false; 
    } else { 
      _emailText.setError(null); 
    } 
    if (password.isEmpty() || password.length() < 6 || password.length() > 15) { 
     Typeface fontt = Typeface.createFromAsset(getAssets(),"fonts/ir.ttf"); 
     SpannableStringBuilder ssbuilder=new SpannableStringBuilder("Pass between 5 to 16"); 
     ssbuilder.setSpan(new CustomTypefaceSpan("",fontt),0,ssbuilder.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE); 
     _passwordText.setError(ssbuilder); 
     valid = false; 
    } else { 
     _passwordText.setError(null); 
    } 
    return valid; 
} 

et voici mon style.xml:

<style name="TextLabel" parent="TextAppearance.AppCompat"> 
     <!-- Hint color and label color in FALSE state --> 
     <item name="android:textColorHint">@color/white</item> 
     <item name="android:textSize">20sp</item> 
     <!-- Label color in TRUE state and bar color FALSE and TRUE State --> 
     <item name="colorAccent">@color/white</item> 
     <item name="colorControlNormal">@color/white</item> 
     <item name="colorControlActivated">@color/white</item> 
    </style> 
+0

montre comment vous initialisez les deux edittext. –

+1

essayer de supprimer "android: theme =" @ style/TextLabel "" –

+0

@VivekSolanki c'était le problème, mais maintenant je ne sais pas quel est le problème avec ce style qui fait planter l'application? – maktaf

Répondre

1

Le problème était le parent du style que j'étais le réglage était censé être le

parent="Theme.AppCompat.Light.NoActionBar" 
+0

Belle réponse j'ai voté il m'aide. –