Step 1) Define your layout, name your widgets very well.
Step 2) Define class members for each of the fields that will be used multiple times
public class MainActivity extends ActionBarActivity {
//during the life-span of the app we will access these fields many times
private EditText valueEnteredEditText;
private TextView resultingValueTextView;
Step 3) Find the right layout items by ID and inflate them.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
valueEnteredEditText = (EditText) findViewById(R.id.valueEntered);
resultingValueTextView = (TextView) findViewById(R.id.resultingValue);
addListenerToValueEnteredEditText();
createConversionSelectorSpinner();
}
Step 4) Add a listener that will react to a value entered
No comments:
Post a Comment