Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

My XML code keeps crashing my app, what is wrong with it?

I dont know what wrong with it but it’s just crashing my app, if you need i will post my java code later cause stack isnt letting me to do it now.When i comment EditTexts it working fine but not as needed so i believe something is wrong with it

<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView
    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=".MainActivity">

        <EditText
            android:id="@+id/A"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:inputType="number"/>

        <EditText
            android:id="@+id/B"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:inputType="number"/>
        <EditText
            android:id="@+id/C"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:inputType="number"/>
        <Button
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/calculate"
            android:text="calculate"
            />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/output"
            />


</androidx.core.widget.NestedScrollView>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

(Nested)ScrollView can have only one direct child. Basically, ScrollView takes care of scrolling but needs just one element to scroll.

<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView
    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=".MainActivity">

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

        <EditText
            android:id="@+id/A"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:inputType="number"/>
        <EditText
            android:id="@+id/B"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:inputType="number"/>
        <EditText
            android:id="@+id/C"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:inputType="number"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:id="@+id/calculate"
            android:text="calculate" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:id="@+id/output" />

    </LinearLayout >

</androidx.core.widget.NestedScrollView>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading