midorikocak / currency-picker-android

A simple library that displays a beautiful list of all the currencies allowing the user to pick the currency she wishes and provide details like country code, iso code name, symbol and flag.
Apache License 2.0
69 stars 32 forks source link

Can i make a call in a different class to set the selected currency? #9

Open Srinathnath opened 5 years ago

Srinathnath commented 5 years ago

Sorry to bother this is indeed a nice library, I am however wondering how can I get the display the selected currency in a simple budget app, what can I call? budgetLineAmount.setText(CurrencyPicker.getSelectedCurrency()); just a simple example.

   @Override
        public void onClick(View view) {
            final CurrencyPicker picker = CurrencyPicker.newInstance("Select Currency");  // dialog title
            picker.setListener(new CurrencyPickerListener() {
                @Override
                public void onSelectCurrency(String name, String code, String symbol, int flagDrawableResID) {
                    // Implement your code here
                    Toast.makeText(getApplicationContext(), name + " was selected", Toast.LENGTH_SHORT).show();
                    picker.dismiss();
                }
            });
            picker.show(getSupportFragmentManager(), "CURRENCY_PICKER");

          // withItems();

        }
    });
Sharain7 commented 1 year ago

Can i make a call in a different class to set the selected currency? Yes, you can use Shared Preference to use it across different places.