Проблема Ошибка надувания класса EditText - PullRequest
0 голосов
/ 12 января 2020

Я использую фрагмент В моем приложении android и когда я пытаюсь вызвать home.fragment Ошибка выдает сообщение мне:

01-12 20:18:13.654 24356-24356/com.example.transportor E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.transportor, PID: 24356
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.transportor/com.example.transportor.Maincontant}: android.view.InflateException: Binary XML file line #38: Error inflating class EditText
        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:5235)
        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 #38: Error inflating class EditText
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
        at com.example.transportor.ui.home.HomeFragment.onCreateView(HomeFragment.java:25)
        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881)
        at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2100)
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1874)
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1830)
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
        at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2663)
        at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613)
        at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2624)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:904)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
        at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659)
        at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613)
        at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:246)
        at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:542)
        at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:201)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
        at android.app.Activity.performStart(Activity.java:6017)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2271)
        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:5235) 
        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.content.res.Resources$NotFoundException: Resource "com.example.transportor:drawable/border" (7f070060)  is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f070060 a=-1 r=0x7f070060}
        at android.content.res.Resources.loadDrawableForCookie(Resources.java:2390)
        at android.content.res.Resources.loadDrawable(Resources.java:2330)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
        at android.view.View.(View.java:3731)
        at android.widget.TextView.(TextView.java:639)
        at android.widget.EditText.(EditText.java:65)
        at android.widget.EditText.(EditText.java:61)
        at androidx.appcompat.widget.AppCompatEditText.

Я догадываюсь, что моя проблема с плагином AppCompat вызывает использование Android, но я не знаю точно, в чем реальная проблема.

Домашний фрагмент. xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="80dp">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"

        android:textColor="@color/Gray" />

</LinearLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="429dp"
        android:layout_marginTop="10dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:layout_marginTop="16dp"
            android:orientation="vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:text="Nom du Client"
                android:textColor="@color/colorPrimary" />

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:background="@drawable/border"
                android:hint="Nom de société"
                android:padding="16dp" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:text="Nom de société"
                android:textColor="@color/colorPrimary" />

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:background="@drawable/border"
                android:hint="Inserer Le nom du client"
                android:padding="16dp" />

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:weightSum="2">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="16dp"
                    android:layout_weight="1"
                    android:text="Nom de produit"
                    android:textColor="@color/colorPrimary" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="30dp"
                    android:layout_marginTop="16dp"
                    android:layout_weight="1"
                    android:text="Quantité de produit"
                    android:textColor="@color/colorPrimary" />

            </LinearLayout>

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:weightSum="2">

                <EditText
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:layout_weight="1"
                    android:background="@drawable/border"
                    android:hint="Nom de produit"
                    android:padding="16dp" />

                <EditText
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="5dp"
                    android:layout_marginTop="5dp"
                    android:layout_weight="1"
                    android:background="@drawable/border"
                    android:hint="Quantité de produit"
                    android:padding="16dp"
                    android:paddingLeft="5dp" />
            </LinearLayout>
            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"
                android:background="@color/white"
                android:layout_marginTop="10dp"
                android:text="ajouter des produits au facture"
                android:textColor="@color/colorPrimaryDark"></Button>
            <ListView
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

            </ListView>
        </LinearLayout>
    </ScrollView>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="64dp"
        android:gravity="center"
        android:orientation="vertical">

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:background="@color/colorPrimaryDark"
            android:text="Imprimer"
            android:textColor="@color/white"></Button>
    </LinearLayout>
</LinearLayout>

Домашний. java:

public class HomeFragment extends Fragment {

    private HomeViewModel homeViewModel;

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        homeViewModel =
                ViewModelProviders.of(this).get(HomeViewModel.class);
        View root = inflater.inflate(R.layout.fragment_home, container, false);

        return root;
    }
}

и gradle:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.navigation:navigation-fragment:2.0.0'
    implementation 'androidx.navigation:navigation-ui:2.0.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

    //Retrofit
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'

    //RXjava

    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.7'

    //Material Edit text
    implementation 'com.rengwuxian.materialedittext:library:2.1.4'

    //Material styled dialog
    implementation 'com.github.javiersantos:MaterialStyledDialogs:2.1'


}

1 Ответ

2 голосов
/ 12 января 2020

У вас неверная схема в border.xml. Замените его на

xmlns:android="http://schemas.android.com/apk/res/android"
...