I am currently learning how to program Java in android. I read various artices on how the layouts work with xml. There are some good examples that show this.. However, I have not seen any examples that show you how to access the elements from the layout once they are changed on the screen..
Does anybody know of a good code example to show the onClick Event for buttons.. and the syntax to enter the value that is typed in by the user in and EditText field..
any help is appreciated..
Regards,
Jeff
Here’s a simple example.
Layout:
The Button has an onClick method called getText, and the Edit text has an ID of edit. In the Activity that uses this Layout, you would write the following code:
Alternatively, if your Button XML has an ID but no onClick, like this:
Then you would write the onClick handler in your Activity like this: