Listing 22 Chapter Twojava implements the Tip Calculator logic

package com .manning. unlockingandroid; <—© Package name import com .manning.unlockingandroid.R;

import android, app .Activity; <—© Required imports import java.text.NumberFormat; import android.util.Log; // some imports omitted public class ChapterTwo extends Activity { public static final String tag = "Chapter2"; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle) ; setContentView(R.layout.main);

final EditText mealpricefield = © Reference EditText

(EditText) f indViewByld (R. id.mealprice) ; <-1 for mealprice final TextView answerfield =

(TextView) findViewByld(R.id.answer);

Set up final Button button = (Button) findViewByld(R.id.calculate);

button. setOnClickListener (new Button. OnClickListener () { <1-1

public void onClick(View v) { onClick

0 0

Post a comment