O'Reilly logo

Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android by Michael Eierman, Jakob Iversen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding Code

Our app has only one function, to display the name entered into the EditText when the Display button is pressed. Enter the code in Listing 3.5 before the last curly bracket in the activity Java file:

Listing 3.5 Display Button Code

                                                                                  //1private void initDisplayButton() {    Button displayButton = (Button) findViewById(R.id.buttonDisplay);             //2    displayButton.setOnClickListener(new OnClickListener () {                     //3      @Override      public void onClick(View arg0) {        EditText editName = (EditText) findViewById(R.id.editTextName);         //4        TextView textDisplay = (TextView) findViewById(R.id. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required