-1

I have spinner , and when i start app, default value for spinner will be the first element in adapter. What i want to do is to notify user via Toast if he click element which is already selected.
Is that possible?

Also, for example , if first element is selected, and during program , first element value is changed from adapter, is it possible to refresh spinner so it display new one?

Thanks :)

  • Possible duplicate of [Android Spinner: Get the selected item change event](https://stackoverflow.com/questions/1337424/android-spinner-get-the-selected-item-change-event) – Sebastian M May 26 '18 at 07:56

1 Answers1

0

I think it will help you.

public void onClick(View view) {
if (view.equals(*your default spinner value here*)) {
Toast.makeText(MainActivity.this, "This is default toast message",Toast.LENGTH_SHORT).show();
else if (view.equals(*selected spinner value here*)) {
LayoutInflater inflater = getLayoutInflater();
View toastLayout = inflater.inflate(R.layout.content_custom_toast, (ViewGroup) findViewById(R.id.llCustom));
Toast toast = new Toast(getApplicationContext());
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(toastLayout);
toast.show();}}