gh darvishani
gh darvishani

Reputation: 160

Binary XML file line #23: Error inflating class TextView

i know this question may be asked by another user ...but i can not solve my problem

this is my xml layout that shown on Alert Dialog .... when i doubel click on EditText my app crashed and closed how i can fix this problem

 <ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/scrollView"  >
<LinearLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content"
    android:layout_margin="2dp">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right">

            <Button
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:text="@string/fa_close"
                android:id="@+id/cancel"
                android:background="@color/top_color"
                android:textColor="#FFF"
                android:layout_margin="1dp"
                android:layout_gravity="right"
                />
        </LinearLayout>

        <EditText
            android:layout_width="match_parent"
            android:layout_height="35dp"
            android:background="@drawable/border"

            android:id="@+id/title"

            android:padding="3dp"
            android:textColor="#000"
            android:hint="عنوان"
            android:textSize="16sp" />

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:background="@drawable/border"
            android:id="@+id/body"

            android:padding="3dp"
            android:ems="10"
            android:inputType="textMultiLine"
            android:scrollbars="horizontal"
            android:textColor="#000000"
            android:hint="امروز چطور گذشت"
            android:gravity="top|right"
            android:layout_marginTop="3dp"
            android:textSize="16sp" />

    </LinearLayout>

    <LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="3dp"
    android:gravity="center">

    <Spinner
        android:layout_width="80dp"
        android:layout_height="30dp"
        android:id="@+id/private_item"

        android:entries="@array/private_item"
        android:spinnerMode="dialog"
        android:background="@android:drawable/editbox_dropdown_light_frame"
        android:layout_gravity="left" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:text="انتخاب تصویر جدید"
        android:id="@+id/set_image"
        android:background="@color/top_color"
        android:textColor="#FFF"
        android:layout_margin="1dp"
        android:layout_gravity="right"
        android:padding="5dp" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:text="ویرایش"
        android:id="@+id/ok"
        android:background="@color/top_color"
        android:textColor="#FFF"
        android:layout_margin="1dp"
        android:padding="5dp" />

</LinearLayout>

</LinearLayout> </ScrollView>

Upvotes: 2

Views: 695

Answers (1)

Linh
Linh

Reputation: 60923

You should pass the Activity context to show the dialog like this

public void editPost(Context context,final ListPost  mydata,final int postiotn) { 
    // final Dialog post = new Dialog(MainActivity.currentActivity); 
    final Dialog post = new Dialog(context); 
    ...
}

In your MainActivity

editPost(MainActivity.this, mydata,postiotn);

Upvotes: 1

Related Questions