A while back, I made a little program called TPCalc to do one of my favorite mundane activities, which is to determine the best price for toilet paper at the discount store, using a toy program written in a bunch of different languages. Given that you typically don't flip open your notebook computer at the store, the program really didn't make sense (in any computer language). No longer. Here is the Android version of TPCalc.
No longer do you need to remember that you can simply divide the price by the # of rolls, then divide again by the number of sheets per roll. You can rely on the computer application to remember that for you.
The only interesting thing in the program is that, instead of forcing a recalculation of the total when the "Calculate" button is pressed, it simply moves the focus to the button. That causes the field to defocus, which triggers a recalculation.
button1 = (Button)findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// on a click, just blur what was being typed
button1.requestFocus();
}
});
Sources are in the zip file. The installer is the apk file. MainActivity.java is the hand-written part of the project.
PS - This is my first non-tutorial Android app.
Attachment | Size |
---|---|
TPCalc.zip | 106.26 KB |
TPCalc.apk | 230.89 KB |
tpcalc.jpg | 8.1 KB |
MainActivity.java | 2.99 KB |