0% found this document useful (0 votes)
2 views2 pages

2. Adding Two Numbers

The document is a Java code snippet for an Android application that adds two numbers. It includes a MainActivity class with EditText fields for input, a Button to trigger the addition, and a TextView to display the result. The addition is performed by parsing the input values and updating the TextView with the sum when the button is clicked.

Uploaded by

ashok.rajancse
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

2. Adding Two Numbers

The document is a Java code snippet for an Android application that adds two numbers. It includes a MainActivity class with EditText fields for input, a Button to trigger the addition, and a TextView to display the result. The addition is performed by parsing the input values and updating the TextView with the sum when the button is clicked.

Uploaded by

ashok.rajancse
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Adding Two Numbers

package [Link].myapplication12;

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class MainActivity extends AppCompatActivity {


private EditText n1;
private EditText n2;
private Button add;
private TextView result;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
[Link](this);
setContentView([Link].activity_main);

//[Link](findViewById([Link]), (v, insets) -> {


// Insets systemBars = [Link]([Link]());
// [Link]([Link], [Link], [Link],
[Link]);
// return insets;

n1 = (EditText) findViewById([Link].num1);
n2 = (EditText) findViewById([Link].num2);
add = (Button) findViewById([Link].b1);
result = (TextView) findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View v) {
int s = [Link]([Link]().toString()) +
[Link]([Link]().toString());
[Link]("Answer:" + [Link](s));
}

});
}
}

You might also like