1

' android.view.InflateException : Binary XML file line # 54 : Error inflating class EditText ' is generated when the login screen is completed and run due to the project. How do I solve this?

Below are the error contents and source.

error : E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.min.project, PID: 2930 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.min.project/com.example.min.project.LoginActivity}: android.view.InflateException: Binary XML file line #54: Error inflating class EditText at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) 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:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: android.view.InflateException: Binary XML file line #54: 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 android.view.LayoutInflater.inflate(LayoutInflater.java:365) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) at com.example.min.project.LoginActivity.onCreate(LoginActivity.java:24) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)  at android.app.ActivityThread.access$800(ActivityThread.java:151)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5254)  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:903)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)  Caused by: android.content.res.Resources$NotFoundException: Resource "com.example.min.project:drawable/round_background" (7f060068) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060068 a=-1 r=0x7f060068} at android.content.res.Resources.loadDrawableForCookie(Resources.java:2441) at android.content.res.Resources.loadDrawable(Resources.java:2381) at android.content.res.TypedArray.getDrawable(TypedArray.java:749) at android.view.View.(View.java:3737) at android.widget.TextView.(TextView.java:637) at android.widget.EditText.(EditText.java:65) at android.widget.EditText.(EditText.java:61) at android.support.v7.widget.AppCompatEditText.(AppCompatEditText.java:64) at android.support.v7.widget.AppCompatEditText.(AppCompatEditText.java:60) at android.support.v7.app.AppCompatViewInflater.createEditText(AppCompatViewInflater.java:191) at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:113) at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1035) at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1092) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725) 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 android.view.LayoutInflater.inflate(LayoutInflater.java:365)  at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)  at com.example.min.project.LoginActivity.onCreate(LoginActivity.java:24)  at android.app.Activity.performCreate(Activity.java:5990)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)  at android.app.ActivityThread.access$800(ActivityThread.java:151)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5254)  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:903)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

LoginActivity source :

package com.example.min.project;

import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.Volley;

import org.json.JSONObject;

public class LoginActivity extends AppCompatActivity {

    private AlertDialog dialog;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);


        final EditText idText = (EditText) findViewById(R.id.idText);
        final EditText passwordText = (EditText)findViewById(R.id.passwordText);
        final Button loginButton = (Button) findViewById(R.id.loginButton);

        loginButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String id = idText.getText().toString();
                String pw = passwordText.getText().toString();

                Response.Listener<String> responseLister = new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try
                        {
                            JSONObject jsonResponse = new JSONObject(response);
                            boolean success = jsonResponse.getBoolean("success");
                            if(success){
                                AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
                                dialog = builder.setMessage("success login")
                                        .setPositiveButton("확인", null)
                                        .create();
                                dialog.show();
                                Intent intent = new Intent(LoginActivity.this, NoticeActivity.class);
                                LoginActivity.this.startActivity(intent);
                                finish();
                            }
                            else{
                                AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
                                dialog = builder.setMessage("Please check your ID and password.")
                                        .setNegativeButton("Retry", null)
                                        .create();
                                dialog.show();
                            }

                        }
                        catch (Exception e)
                        {
                            e.printStackTrace();
                        }
                    }
                };
                LoginRequest loginRequest = new LoginRequest(id, pw, responseLister);
                RequestQueue queue = Volley.newRequestQueue(LoginActivity.this);
                queue.add(loginRequest);
            }
        });

    }
    protected void onStop(){
        super.onStop();
        if(dialog != null)
        {
            dialog.dismiss();
            dialog = null;
        }
    }
}

Login.xml :

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".LoginActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:layout_editor_absoluteX="0dp"
        tools:layout_editor_absoluteY="51dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="227dp"
            android:background="@color/colorLogin"
            android:orientation="vertical">

            <ImageView
                android:layout_width="125dp"
                android:layout_height="125dp"
                android:layout_gravity="center"
                android:layout_marginTop="20dp"
                android:src="@drawable/sunmoon" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginTop="10dp"
                android:text="scholl"
                android:textColor="#000000"
                android:textSize="25dp"
                android:textStyle="bold" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="attend system"
                android:textColor="#000000"
                android:textSize="18dp"
                android:textStyle="bold" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <EditText
                android:id="@+id/idText"
                android:layout_width="230dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginTop="50dp"
                android:background="@drawable/round_background"
                android:drawableLeft="@drawable/ic_person_black_24dp"
                android:hint="Id"
                android:padding="10dp"
                android:textColor="#808080"
                android:textColorHint="#808080" />

            <EditText
                android:id="@+id/passwordText"
                android:layout_width="230dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginTop="10dp"
                android:background="@drawable/round_background"
                android:drawableLeft="@drawable/ic_lock_black_24dp"
                android:hint="Pw"
                android:inputType="textPassword"
                android:padding="10dp"
                android:textColor="#808080"
                android:textColorHint="#808080" />

            <Button
                android:id="@+id/loginButton"
                android:layout_width="280dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginTop="10dp"
                android:background="@color/colorPrimaryDark"
                android:text="login"
                android:textColor="#ffffff"
                android:textSize="20dp"
                android:textStyle="bold" />
        </LinearLayout>


    </LinearLayout>

</android.support.constraint.ConstraintLayout>

1 Answer 1

1

You have a background like below round_background.xml. Find by ctrl + shift + n and type this xml name.

Move that to res>drawable.

Sign up to request clarification or add additional context in comments.

6 Comments

Thank you for answering the question. I have a question. Shouldn't it overlap padding in ' login.xml ' and padding in ' round_background.xml '?
You should not use padding in round_background.xml. Just use this in your EditText.
' < Padding Android : left = " 45 px " Android : top = " 15 px " Android : right = " 45 px " Android : bottom = " 15 px " / " Isn't it possible to use padding like this?
Because you can use that background in other views also, so you should use paddingTop, paddingBottom in EditText instead of background drawable.
The solution is to remove padding of ' EditText ' instead of ' round_background ' for Box rounding. Thank you very much. May I ask you a question?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.