Let's take a whirlwind tour of some of those previously unexplored/unused items from the palette, and then we can drag a bunch of them onto a layout and see some of the methods they have that might be useful. We can then implement a project to put them all to use.
We already explored Button
and TextView
in the last chapter. Let's take a closer look at some more alongside them.
The EditText
widget does what the name suggests. If we make an EditText
widget available to our users, then they will indeed be able to edit the text in it. We saw this in an earlier chapter, but we didn't actually achieve anything with it. What we didn't see was how to capture the information from within it, or where we would type this text-capturing code.
The following block of code assumes that we have declared an object of type EditText
and used it to get a reference to EditText
in our XML layout. We might write code like the following for a button click, perhaps...