fobus
fobus

Reputation: 2058

android.view.InflateException - Error inflating class android.widget.EditText

Hello I'm trying to show a custom AlertDialog on the screen. I'm inflating an layout into the dialog, this layout includes Two TextViews, one RatingBar and one EditText.

When I try to popup the dialog I'm getting this exception :

E/AndroidRuntime(12989): android.view.InflateException: Binary XML file line #25: Error inflating class android.widget.EditText

Important point is this error occurs on Android 2.3.x Devices, It works great on 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();

    }

How do I show AlertDialog

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

Upvotes: 1

Views: 6041

Answers (2)

Eric Fettman
Eric Fettman

Reputation: 51

Deleted my EditView (Plain Text text field), dropped another one into content_....xml and did not change any styling this time. Everything ran correctly with the default styling on the EditView.

Upvotes: 0

Neoh
Neoh

Reputation: 16164

Replace

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

with

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

Upvotes: 1

Related Questions