i am useing java xml to make android apps.

in my xml file i have a 2 edittext where user will enter 2 numbers.

 <EditText
        android:id="@+id/ET_FIRST"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginTop="50dp"
            android:hint="Enter 1st number hint"
            android:inputType="numberDecimal"
                android:textColor="#ffffff"
                android:textSize="25dp"
                android:textStyle="bold" />


        <EditText
        android:id="@+id/ET_SECOND"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginTop="100dp"
        android:hint="Enter 2nd number hint"
        android:inputType="numberDecimal"
        android:textColor="#ffffff"
        android:textSize="25dp"
        android:textStyle="bold" />

than in java file i going to add those 2 numbers.
first get two number from edittext and store in value1, value2

// TODO Auto-generated method stub
            String value1 = first.getText().toString();
            String value2 = second.getText().toString();


than turn them in int but this two line give me error.



            int num1 = Integer.parseInt(value1);
            int num2 = Integer.parseInt(value2);
            int answer = num1 + num2;
            total.setText(ansser);

wow great thanks for this code

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.