Advertisement
MateuszGrabarczyk

spinnerM

Nov 22nd, 2022
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. package com.example.hanakpiskozub;
  2.  
  3. import android.content.Context;
  4. import android.util.AttributeSet;
  5. import android.widget.Spinner;
  6.  
  7. public class SpinnerM extends Spinner {
  8.     public SpinnerM(Context context) {
  9.         super(context);
  10.     }
  11.  
  12.     public SpinnerM(Context context, AttributeSet attributes) {
  13.         super(context, attributes);
  14.     }
  15.  
  16.     @Override
  17.     public void setSelection(int position, boolean animate) {
  18.         boolean sameSelected = position == getSelectedItemPosition();
  19.         super.setSelection(position, animate);
  20.         if(sameSelected){
  21.             getOnItemSelectedListener().onItemSelected(this, getSelectedView(),position, getSelectedItemId());
  22.         }
  23.     }
  24.  
  25.     @Override
  26.     public void setSelection(int position){
  27.         boolean sameSelected = position == getSelectedItemPosition();
  28.         super.setSelection(position);
  29.         if(sameSelected){
  30.             getOnItemSelectedListener().onItemSelected(this, getSelectedView(), position, getSelectedItemId() );
  31.         }
  32.     }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement