0

I create a login layout but when i try to write this line

setContentView(R.layout.activity_login);

it shows me an error

ERROR: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.look.instragramclone/com.example.look.instragramclone.Likes.LikesActivity}: android.view.InflateException: Binary XML file line #27: android.support.design.widget.TextInputEditText cannot be cast to android.view.ViewGroup

i can not find the problem. i am adding relevant codes

I tried adding these library:

implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0'

//Design support library for coordinator layout implementation 'com.android.support:design:28.0.0'

implementation 'com.github.ittianyu:BottomNavigationViewEx:2.0.2'

//Circular Image implementation 'de.hdodenhof:circleimageview:3.0.0'

//universal image loader implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

login layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
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="wrap_content"
        android:orientation="vertical"
        android:paddingTop="55dp"
        android:paddingLeft="25dp"
        android:paddingRight="25dp">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="70dp"
            android:src="@drawable/instagram_logo"
            android:layout_gravity="center"
            android:layout_marginBottom="25dp"/>

        <android.support.design.widget.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp">

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textEmailAddress"
                android:hint="Email"
                android:id="@+id/input_email"/>

        </android.support.design.widget.TextInputEditText>

        <android.support.design.widget.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp">

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textPassword"
                android:hint="Password"
                android:id="@+id/input_password"/>

        </android.support.design.widget.TextInputEditText>

        <android.support.v7.widget.AppCompatButton
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="25dp"
            android:text="Login"
            android:id="@+id/btn_Login"
            android:padding="12dp"
            android:background="@drawable/white_rounded_btn"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="25dp"
            android:text="No account yet? Create one"
            android:gravity="center"
            android:textSize="16dp"
            android:id="@+id/link_singup"
            android:textColor="@color/blue"/>

    </LinearLayout>

    <ProgressBar
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:id="@+id/loginRequestLoadingProgressBar"
        android:layout_centerInParent="true"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Pleasr wait..."
        android:textColor="@color/black"
        android:textSize="20sp"
        android:layout_alignBottom="@+id/loginRequestLoadingProgressBar"
        android:layout_alignStart="@id/loginRequestLoadingProgressBar"
        android:layout_alignEnd="@id/loginRequestLoadingProgressBar"/>


</RelativeLayout>

java:

private static final String TAG = "LikesActivity";

private Context mContext = LikesActivity.this;

private static final int ACTIVITY_NO = 3;


@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_login);
    -->Note: this line shows the error

    //setupNavigationView();
}
/***BottomNavigationView setup***/

private void setupNavigationView(){

    BottomNavigationViewEx bottomNavigationViewEx = findViewById(R.id.bottomNavViewBar);
    BottomNavigationViewHelper.setupBottomNavigationView(bottomNavigationViewEx);
    BottomNavigationViewHelper.enableNavigation(mContext,bottomNavigationViewEx);
    Menu menu = bottomNavigationViewEx.getMenu();
    MenuItem menuItem = menu.getItem(ACTIVITY_NO);
    menuItem.setChecked(true);
}
0

3 Answers 3

2

use TextInputLayout insted of TextInputEdittext.

below code is for textinputlayout use:

<android.support.design.widget.TextInputLayout
   android:id="@+id/usernameWrapper"
   android:layout_width="match_parent"
   android:layout_height="wrap_content">

<EditText
    android:id="@+id/username"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:inputType="textEmailAddress"
    android:hint="Email"/> 

</android.support.design.widget.TextInputLayout>
Sign up to request clarification or add additional context in comments.

Comments

1

You can not treat TextInputEditText as a ViewGroup by placing a child inside in the following xml -

<android.support.design.widget.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textEmailAddress"
            android:hint="Email"
            android:id="@+id/input_email"/>

    </android.support.design.widget.TextInputEditText>

You need to use it as a view using -

        <android.support.design.widget.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp"/> // close this tag here

Comments

0

I was having the same problem apparently the style for my InputLayout was not configured properly I tried changing that and the error was solved and also we can use EditText instead of InputEditText inside InputTextLayout

Comments

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.