2013-07-22 2 views
0

Bonjour J'essaie de montrer un AlertDialog personnalisé sur l'écran. Je gonfle une mise en page dans la boîte de dialogue, cette disposition inclut deux TextViews, un RatingBar et un EditText.android.view.InflateException - Erreur de gonflement de la classe android.widget.EditText

Lorsque je tente de dialogue contextuellle Je reçois cette exception:

E/AndroidRuntime (12989): android.view.InflateException: ligne fichier XML binaire # 25: Erreur android classe gonflage .widget.EditText

point important est cette erreur se produit sur les appareils Android 2.3.x, Il fonctionne très bien sur Android 4.x

dialog_comment.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/RelativeLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <RatingBar 
     android:id="@+id/DialogCommentRatingBar" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/textView1" 
     android:stepSize="1" /> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/DialogCommentRatingBar" 
     android:text="Yorumunuz" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

    <EditText 
     android:id="@+id/DialogCommentComment" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/textView2" 
     android:background="?android:attr/editTextBackground" 
     android:ems="10" 
     android:gravity="top" 
     android:inputType="textMultiLine" > 
    </EditText> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:text="Oyunuz" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

</RelativeLayout> 

CommentDialog.java

@Override 
    public Dialog onCreateDialog(Bundle savedInstanceState) { 

     LayoutInflater inflater=getActivity().getLayoutInflater(); 
     final View view=inflater.inflate(R.layout.dialog_comment, null); 

     final RatingBar rating=(RatingBar)view.findViewById(R.id.DialogCommentRatingBar); 
     final EditText comment=(EditText)view.findViewById(R.id.DialogCommentComment);  

     AlertDialog.Builder builder=new AlertDialog.Builder(getActivity()); 

     builder.setView(view); 

     builder.setTitle("Enter Your Comment!"); 
     return builder.create(); 

    } 

Comment afficher AlertDialog

 FragmentManager fm = getSupportFragmentManager(); 
     CommentDialog commentDialog = new CommentDialog(); 
     commentDialog.show(fm, "fragment_comment_dialog"); 
+0

Essayez ceci: LayoutInflater inf = (LayoutInflater) context.getSystemService (Context.LAYOUT_INFLATER_SERVICE); Peut-être que ça aide. En fait, essayez de déboguer. Je pense que vous donnez une vue nulle. –

+1

@fobus essayez de supprimer l'attribut background de l'EditText et de voir si cela fait une différence – Blackbelt

+1

supprimer cette ligne android: background = "? Android: attr/editTextBackground" à partir de EditText & mettre à jour cette ligne finale Voir vue = inflater.inflate (R .layout.dialog_comment, null, false); –

Répondre

1

Remplacer

android:textAppearance="?android:attr/textAppearanceLarge" 

avec

android:textAppearance="@android:style/TextAppearance.Large" 
+0

Merci, mais il n'a pas résolu mon problème. – fobus

0

J'ai supprimé mon EditView (champ de texte en texte brut), en ai laissé tomber un autre dans le contenu _.... xml et n'ai modifié aucun style cette fois. Tout s'est déroulé correctement avec le style par défaut sur le EditView.

Questions connexes