android.view.InflateException: строка двоичного XML-файла # 48: ошибка надувания класса TextView - PullRequest
0 голосов
/ 20 сентября 2018

Я проверял много тем, но не получил ответа.Код застрял на setContentView(R.layout.activity_entrance); За исключением

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gootax.driver/com.gootax.driver.EntranceActivity}: android.view.InflateException: Binary XML file line #48: Binary XML file line #48: Error inflating class TextView
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2464)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524)
    at android.app.ActivityThread.access$900(ActivityThread.java:154)
......
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 24: TypedValue{t=0x3/d=0x5ef "res/color/secondary_text_material_dark.xml" a=1 r=0x1060166}
    at android.content.res.TypedArray.getColor(TypedArray.java:447)
    at android.widget.TextView.<init>(TextView.java:745)
    at android.widget.TextView.<init>(TextView.java:678)

Хорошо, я проверяю макет и его 48 строк.

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFE6E6E6"
    android:orientation="vertical">
    <!--android:background="?attr/bg_main"-->

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="3">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal|center_vertical"
            android:layout_marginTop="20dp"
            android:background="@android:color/transparent"
            android:src="@drawable/pic"
            tools:ignore="ContentDescription" />
    </FrameLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1">


        <FrameLayout
            android:id="@+id/framelayout_servicelist"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">


            <LinearLayout
                android:id="@+id/linearlayout_list_service"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="30dp"
                android:background="#FFFFFFFF"
                android:orientation="vertical"
                android:paddingBottom="30dp">
                <!--android:background="?attr/bg_second"-->

                <TextView   <-- This line 48
                    android:id="@+id/textview_entrance_info"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="30dp"
                    android:layout_marginLeft="50dp"
                    android:layout_marginRight="50dp"
                    android:layout_marginTop="30dp"
                    android:gravity="center_horizontal"
                    android:textColor="@color/grey_text"
                    android:text="@string/text_entrancefragment_entrance" />
                <ListView
     .....

У меня есть собственная тема

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppThemeLight" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    <item name="bg_main">@color/bg_main_light</item>
    <item name="bg_second">@color/bg_second_light</item>
    <item name="bg_second_comment">@color/bg_second_comment_light</item>
    <item name="text_main">@color/text_main_light</item>
    <item name="text_subscribe">@color/text_subscribe_light</item>
    <item name="android:textSize">@dimen/textsize_textviews</item>
    <item name="android:textColorSecondaryInverse">@color/text_main_dark</item>
</style>

А в чем проблема?Моя тема переопределяет тему по умолчанию и не может пропустить XML.У меня нет этого ресурса: "res / color / primary_text_material_dark.xml", но он мне не нужен.Пожалуйста, помогите мне

1 Ответ

0 голосов
/ 20 сентября 2018

Спасибо за помощь, @ UmangBurman.

Моя ошибка была с AppPreferences.При запуске приложения прочитайте тему установки и установите ее.Я думаю, что это было неправильно.

if (appPreferences.getText("theme").length() > 0) {
            setTheme(Integer.valueOf(appPreferences.getText("theme")));
        } else {
            setTheme(AppParams.THEME_DEFAULT);
            appPreferences.saveText("theme", String.valueOf(AppParams.THEME_DEFAULT));
        }
    setTheme(AppParams.THEME_DEFAULT);
...