单击调用片段活动的按钮时,应用程序崩溃

时间:2018-04-12 05:08:53

标签: android android-dialogfragment

我正在使用Fragment活动,我在其中使用recycler adapter调用数据。它将显示数据库中的所有数据。然后,我将通过单击特定的recyclerview项目移动到某个活动。在那个活动中,我必须转移到另一个扩展FragmentActivity(android.support.v4.app.FragmentActivity)的活动,其中我有一个按钮,用于通过使用Dialog Fragment在一个视图中显示日期和时间。当我点击它并收到以下错误时,应用程序崩溃。

android.view.InflateException: Binary XML file line #10: Error inflating class fragment

我需要澄清一下,在片段之间调用活动然后调用FragmentActivity会有什么问题吗?

提前致谢。

更新

XML代码:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="#fff"
    android:weightSum="11">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal"
        android:weightSum="1">
        <TextView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:background="@drawable/toolbar"
            android:text="MOVE CAB"
            android:textColor="#000"
            android:textSize="15sp"
            android:textStyle="bold" />
    </LinearLayout>
    <ImageView
        android:id="@+id/cab_image"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2.5"
        android:src="@drawable/cars"
        android:padding="30sp"/>
    <TextView
        android:id="@+id/cab_text"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.7"
        android:gravity="center"
        android:text="Prime Seden"
        android:textColor="#444"
        android:textSize="17sp"/>
    <ImageView
        android:paddingTop="2sp"
        android:layout_marginLeft="10sp"
        android:layout_marginRight="10sp"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.4"
        />
    <ImageView
        android:paddingTop="2sp"
        android:layout_marginLeft="10sp"
        android:layout_marginRight="10sp"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.4"
        android:src="@drawable/picl"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal"
        android:weightSum="2">
        <TextView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center|left"
            android:paddingLeft="20sp"
            android:text="Select color"
            android:textColor="#999" />
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:weightSum="2"
            android:orientation="horizontal">
            <RelativeLayout
                android:gravity="center|left"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="0.5">
                <android.support.v7.widget.RecyclerView
                    android:id="@+id/rv"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:clipToPadding="false"/>
            </RelativeLayout>
            <CheckBox
                android:layout_marginLeft="20sp"
                style="@android:style/Widget.CompoundButton.RadioButton"
                android:gravity="center|left"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1.2"
                android:textColor="#999"
                android:theme="@style/RadioButtonStyle"
                android:textSize="14sp"
                android:id="@+id/radio_ninjas"
                android:text="Any color"/>
        </LinearLayout>
    </LinearLayout>
    <ImageView
        android:paddingTop="2sp"
        android:layout_marginLeft="10sp"
        android:layout_marginRight="10sp"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.4"
        android:src="@drawable/picl"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.8"
        android:orientation="horizontal"
        android:weightSum="2">
        <TextView
            android:gravity="center|left"
            android:paddingLeft="20sp"
            android:text="Select no.of seat"
            android:textColor="#999"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"/>
        <Spinner
            android:id="@+id/number_spinner"
            android:layout_width="0dp"
            android:layout_marginLeft="20sp"
            android:layout_marginRight="20sp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            style="@android:style/Widget.Holo.Light.Spinner"
            />
    </LinearLayout>
    <ImageView
        android:paddingTop="2sp"
        android:layout_marginLeft="10sp"
        android:layout_marginRight="10sp"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.4"
        android:src="@drawable/picl"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1.25"
        android:orientation="horizontal"
        android:weightSum="2">
        <TextView
            android:gravity="center|left"
            android:paddingLeft="20sp"
            android:text="Ac / Non Ac"
            android:textColor="#999"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"/>
        <RadioGroup
            android:id="@+id/rg1"
            android:layout_width="0dp"
            android:orientation="vertical"
            android:layout_marginLeft="20sp"
            android:layout_marginRight="20sp"
            android:layout_height="match_parent"
            android:layout_weight="1" >
            <RadioButton
                android:id="@+id/ac_rb"
                android:gravity="center"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#999"
                android:theme="@style/RadioButtonStyle"
                android:checked="true"
                android:textSize="14sp"
                android:text="Ac"/>
            <RadioButton
                android:id="@+id/nonac_rb"
                android:gravity="center"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:textColor="#999"
                android:theme="@style/RadioButtonStyle"
                android:textSize="14sp"
                android:text="non-Ac"/></RadioGroup>
    </LinearLayout>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1.35"/>
    <LinearLayout
        android:background="#999"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.80"
        android:orientation="horizontal"
        android:weightSum="1"
        >
        <Button
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
            android:text="RIDE NOW"
            android:textColor="#f79a06"
            android:textSize="15sp"
            android:layout_marginRight="0.1dp"
            android:id="@+id/ride_start"
            android:gravity="center"
            android:background="#000"/>
        <Button
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
            android:text="RIDE LATER"
            android:textColor="#f79a06"
            android:textSize="15sp"
            android:id="@+id/ride_later"
            android:layout_marginLeft="0.1dp"
            android:gravity="center"
            android:background="#000"/></LinearLayout></LinearLayout>
<LinearLayout
    android:visibility="gone"
    android:id="@+id/fare_estimation_ll"
    android:layout_gravity="bottom"
    android:layout_width="match_parent"
    android:layout_height="300sp"
    android:background="#fff"
    android:orientation="vertical"
    android:weightSum="6">
    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.3"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.7"
        android:text="Fares are higher than normal"
        android:textColor="#000"
        android:gravity="center"
        android:background="#eee"/>
    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.3"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal"
        android:weightSum="2"
        >
        <TextView
            android:layout_marginLeft="8sp"
            android:layout_marginRight="2sp"
            android:background="@drawable/fare_button_border"
            android:gravity="center"
            android:text="Rs. 149 Micro"
            android:layout_width="0dp"
            android:textColor="@color/black"
            android:layout_height="match_parent"
            android:layout_weight="1"/>
        <TextView
            android:background="@drawable/fare_button_border"
            android:layout_marginLeft="8sp"
            android:layout_marginRight="8sp"
            android:gravity="center"
            android:layout_width="0dp"
            android:text="Rs. 84 Share your ride"
            android:textColor="@color/black"
            android:layout_height="match_parent"
            android:layout_weight="1"/>
    </LinearLayout>
    <View
        android:background="@drawable/underline"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.3"/>
    <LinearLayout
        android:layout_marginTop="15sp"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal"
        android:weightSum="2"
        >
        <TextView
            android:layout_marginLeft="8sp"
            android:layout_marginRight="2sp"
            android:paddingLeft="20sp"
            android:gravity="center|left"
            android:text="Personal"
            android:layout_width="0dp"
            android:textColor="@color/black"
            android:layout_height="match_parent"
            android:layout_weight="1"/>
        <TextView
            android:layout_marginLeft="8sp"
            android:layout_marginRight="2sp"
            android:paddingLeft="20sp"
            android:gravity="center"
            android:text="Set up payment"
            android:layout_width="0dp"
            android:textColor="@color/black"
            android:layout_height="match_parent"
            android:layout_weight="1"/>
    </LinearLayout>
    <View
        android:background="@drawable/underline"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.3"
        android:layout_marginBottom="10sp"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.7"
        android:textColor="#000"
        android:gravity="center|left"
        android:paddingLeft="28sp"
        android:text="Apply Coupon"/>
    <View
        android:background="@drawable/underline"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.3"/>
    <Button
        android:id="@+id/confirm_booking"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1.1"
        android:background="#111"
        android:gravity="center"
        android:textSize="17sp"
        android:text="CONFIRM BOOKING"
        android:textColor="#f79a06"/>
</LinearLayout>
</FrameLayout>

堆栈跟踪

    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2308)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2368)
    at android.app.ActivityThread.access$800(ActivityThread.java:144)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1285)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5233)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
 Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class fragment
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:414)

0 个答案:

没有答案