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. ...

Get Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.