Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7532447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:27:22+00:00 2026-05-30T05:27:22+00:00

I need help understanding how to accomplish math between different EditText views. I am

  • 0

I need help understanding how to accomplish math between different EditText views. I am not asking someone to write me the code but maybe explain what is involved to get this done.

I wanted to post a picture of this but as a new user I can not. Basicly I have a EditText for the following: Width, Length, Eave Height, Pitch.

I have ID’s for all the TextViews I just dont know how to program the behind the scenes math involved to make them work. I do have the equations needed to perform the math just not sure where and how to put them in java.

Basicly I need the user to enter a number in each of the top 4 boxes. I need to use an equation to generate the answer that will be displayed in the “SQFT” box. The user will also input a number in a cost box which will generat a “Total” that needs to be displayed in a separate TextView.

Any help would be appreciated, even if it is to point me in a direction of a tutorial to get me started. Thanks for your help.

Just to show what type of math I need to use, below is the equation I use for excel to calulate.

(length+width)*(Eave+1)*2 + (((width/2)/12*Pitch)*(width/2)*2)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T05:27:25+00:00Added an answer on May 30, 2026 at 5:27 am

    I’m not sure if you don’t know how to extract the numbers entered in the EditTexts, how to actually do the math calculation, how to let the user initiate the calculate or how to present it.

    I created a small demo that has 2 EditTexts, and a TextView that displays the sum of the numbers entered. The user does not need to press any buttons to perform the calculation, it is performed automatically every time the user updates the text (I assumed this is what you wanted).

    Please note this code is not good code, it uses lots of internal anonymous classes etc but it supposed to demonstrate the mechanics of how to do this.

    This is the main.xml layout file:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal" >
    
        <EditText
            android:id="@+id/a"
            android:hint="input a"
            android:inputType="number"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:minWidth="60dp"/>
        <EditText 
            android:id="@+id/b"
            android:hint="input b"
            android:inputType="number"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:minWidth="60dp"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:text="a+b = " />
        <TextView
            android:id="@+id/total"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="10dp" />
    
    </LinearLayout>
    

    And this is the sample Activity:

    package com.example;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.text.Editable;
    import android.text.TextWatcher;
    import android.util.Log;
    import android.widget.EditText;
    import android.widget.TextView;
    
    public class SumActivity extends Activity
    {
        private int a;
        private int b;
        private TextView totalOutput;
    
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            EditText inputA = (EditText) findViewById(R.id.a);
            EditText inputB = (EditText) findViewById(R.id.b);
            totalOutput = (TextView) findViewById(R.id.total);
            inputA.addTextChangedListener(new TextChangedListener()
            {
    
                @Override
                public void numberEntered(int number)
                {
                    a = number;
                    updateTotal();
                }
            });
            inputB.addTextChangedListener(new TextChangedListener()
            {
    
                @Override
                public void numberEntered(int number)
                {
                    b = number;
                    updateTotal();
                }
            });
        }
    
        private void updateTotal()
        {
            int total = a + b; // This is where you apply your function
            totalOutput.setText("" + total); // need to do that otherwise int will
                                                // be treated as res id.
        }
    
        private abstract class TextChangedListener implements TextWatcher
        {
    
            public abstract void numberEntered(int number);
    
            @Override
            public void afterTextChanged(Editable s)
            {
                String text = s.toString();
                try
                {
                    int parsedInt = Integer.parseInt(text);
                    numberEntered(parsedInt);
                } catch (NumberFormatException e)
                {
                    Log.w(getPackageName(), "Could not parse '" + text + "' as a number", e);
                }
            }
    
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after)
            {
            }
    
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count)
            {
            }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help understanding this bit of code pre { white-space: pre; white-space:
I need help understanding how to write a permutation algorithm. (if this is even
I had to take over a project where someone quit and need help understanding
I need help understanding how to implement this part of PHP code in Ruby.
Need some help understanding what the difference between these two redirects is: header( HTTP/1.1
I need help in understanding the following C++ code (in a .h file): bool
I need some help understanding why the ArrayList is not being populated, I am
I need help understanding some C++ operator overload statements. The class is declared like
I'm a SQL noob, and I need a little bit of help understanding the
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.