This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double itemPrice = cursor.getDouble(priceIndex); | |
String itemPriceFormatted = String.format(Locale.ROOT, "%.2f", itemPrice); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mPriceEditText = (EditText) findViewById(R.id.price_field); | |
mPriceEditText.setFilters(new InputFilter[]{new DecimalDigitsInputFilter(5, 2)}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Content URI for the existing pet (null if it's a new pet) | |
*/ | |
private Uri mCurrentPetUri; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
mCurrentPetUri = getIntent().getData(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void showDeleteConfirmationDialog() { | |
AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
builder.setMessage(R.string.delete_all_dialog_msg); | |
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
// close the window on pressing Cancel button | |
if (dialog != null) | |
dialog.dismiss(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Setup the dropdown spinner that allows the user to select the gender of the pet. | |
*/ | |
private void setupSpinner() { | |
// Create adapter for spinner. The list options are from the String array it will use | |
// the spinner will use the default layout | |
ArrayAdapter genderSpinnerAdapter = ArrayAdapter.createFromResource(this, | |
R.array.array_gender_options, android.R.layout.simple_spinner_item); | |
// Specify dropdown layout style - simple list view with 1 item per line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The custom SearchView provides following features: | |
* 1) Located below the App Name with the effect of 'multi-level' toolbar. | |
* 2) Expanded to the full width of the screen with even margin from the both edges. | |
* 3) The search icon is located inside the text field (not really) as opposed to the default 'outing' | |
* when implementing setIconifiedByDefault(false); | |
* 4) Uses semi-transparent background, icons and he hint text. | |
* 5) Default underline of the text field is removed. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
Toolbar mActionBarToolbar = (Toolbar) findViewById(R.id.toolbar); | |
setSupportActionBar(mActionBarToolbar); | |
getSupportActionBar().setDisplayShowHomeEnabled(true); | |
getSupportActionBar().setIcon(R.drawable.xml_app_logo); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android:imeOptions="actionSearch|flagNoExtractUi|flagNoFullscreen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onStart() { | |
super.onStart(); | |
Log.d(LOG_TAG, "onStart() called"); | |
} | |
@Override | |
public void onPause() { | |
super.onPause(); | |
Log.d(LOG_TAG, "onPause() called"); |