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 8172527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:48:37+00:00 2026-06-06T21:48:37+00:00

Here i am using two EditTexts for getting some number as integer value ..

  • 0

Here i am using two EditTexts for getting some number as integer value ..

<EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10" >

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/editText2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10" />
     <EditText
        android:id="@+id/editText3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10" />

Now Im planning to do some calculation
some

   int i1,i2,i3;
    String t1,t2,t3;
    EditText et1,et2,et3;
    int result,comp;
  protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       et1=(EditText)findViewById(R.id.editText1);
       et2=(EditText)findViewById(R.id.editText2);
       et3=(EditText)findViewById(R.id.editText3);
    //and also storing to string like
                       t1=et1.getText().toString();
                   t2=et2.getText().toString();
                       t3=et3.getText().toString();
               i1=Integer.parseInt(t1);
               i2=Integer.parseInt(t2);
                   i3=Integer.parseInt(t3);
                       comp=i2-i1;
}

/here int some x=10; my problem is how to check conditions i need to get comp value if its selected (by entering on two EditTexts) else One editText(i3 valsu)
any one help me ….
/

       public int CalculateUsage(int customersUsage)
                {
        int x=10;
        comp= customersUsage;
        if(comp!=0)
        {
        customersUsage=comp;
        result=(customersUsage*x) ;
        }

        else if(i3 !=null)
        {
        customersUsage=i3;
        result=(customersUsage*x) ;
        }
}
  • 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-06-06T21:48:39+00:00Added an answer on June 6, 2026 at 9:48 pm

    Integer.parseInt() throws an Exception if the String representation isn’t actually an integer. You should make a try-catch block and should set the values to 0 respectively, or the desired default value

    try{
        i1=Integer.parseInt(t1);
    } catch(Exception e) {
        i1=0;
    }
    etc...
    

    Because the edit text value is currently “[empty]”.

    EDIT:
    The edit text are currently empty because you haven’t yet set anything to them.
    The ems=”10″ that you have in you layout isn’t the edit text value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my situation. I am using two java.util.HashMap to store some frequently used
i am developing one simple application for android mobile here i am using two
I'm seeing some odd behaviour here using PrincipalContext.ValidateCredentials . The set-up is two Active
Here i am using a radio button to calculate the date difference between two
Using oracle database. Here's how i think the SQLException happens... Say i have two
Here i am using two different functions for calculating CRC16 for any type of
With Qt4 (here using PyQt4) to get the area of intersection of two QWidgets---and
I am getting a problem when I'm using two tables in single DB, My
So here's the dilemma: I'm writing a progam using two different class using two
So in my application I'm using two different Tabhosts.Here is an example TABHOST1 Contains

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.