I am writing a program, which gets two values from two text fields and calculates their result.
The problem is that Java Editor shows me the following errors:
cannot find symbol class EditText
cannot find symbol class Button
cannot find symbol class string
cannot find symbol class variable integer
cannot find symbol class integer
Here is my code:
public class MainActivity extends AppCompatActivity
{
EditText firstNumber;
EditText secondNumber;
Button btnAdd;
TextView total;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
firstNumber = (EditText)findViewById(R.id.firstNumber);
secondNumber = (EditText)findViewById(R.id.secondNumber);
btnAdd = (Button)findViewById(R.id.btnAdd);
total = (TextView)findViewById(R.id.total);
}
public void btnAdd_Click(View view)
{
string getfirstNumber = firstNumber.getText().toString();
string getsecondNumber = secondNumber.getText().toString();
integer totalResult = integer.parseInt(getfirstNumber) + integer.parseInt(getsecondNumber);
total.setText("Total = " + integer.toString(totalResult));
}
}