Skip to content

Instantly share code, notes, and snippets.

@Seth-Johnson
Created June 18, 2014 01:16
Show Gist options
  • Save Seth-Johnson/af01f21c51d7ad6ff90b to your computer and use it in GitHub Desktop.
Save Seth-Johnson/af01f21c51d7ad6ff90b to your computer and use it in GitHub Desktop.
public class TempConverterMain extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_temp_converter_main);
// I'd prefer not to have to declare these twice, so I can use them in my subclass below
Button convertToFButton = (Button) findViewById(R.id.convertToF);
Button convertToCButton = (Button) findViewById(R.id.convertToC);
convertToFButton.setOnClickListener(new myButtonListener());
convertToCButton.setOnClickListener(new myButtonListener());
}
class myButtonListener implements View.OnClickListener {
Button convertToFButton = (Button) findViewById(R.id.convertToF);
Button convertToCButton = (Button) findViewById(R.id.convertToC);
// more code
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment