Download presentation
Presentation is loading. Please wait.
1
Android Programming Lecture 3
2
To add two numbers Place Textfield – Number field
Select EditText , set the property hint PlainTextView from Widget : To display message. Place the button from the widget
3
Button Click function Take MainActivity.java from Java folder.
Write down a public function for button click . Public onButtonClick(View v) //Alt + Enter to import the class. { EditText e1=(EditText)findViewById(R.id.editText);
4
EditText e2=(EditText)findViewById(R. id
EditText e2=(EditText)findViewById(R.id.editText);//Instance TextView t1=(TextView)findViewById(R.id.textView); int n1=Integer.parseInt(e1.getText.toString());
5
int n2=Integer.parseInt(e2.getText.toString());
int sum=n1+n2; T1.setText(Integer.toString(sum)); }
6
To invoke the function in the button click.
Take the Button Property ,onClick(), Select the method from the combobox.
7
To invoke the function in the button click.
Take the Button Property ,onClick(), Select the method from the combobox.
8
Home Work Perform Subtraction,multiplication and division operation.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.