Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 如何在相同的微调器值选择上调用操作大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我从微调器中选择值,当我再次选择相同的值时,不会对单击执行任何操作.

解决方法

使用这个自定义Spinner类……
/** Spinner extension that calls onItemSELEcted even when the SELEction is the same as its prevIoUs value */
public class NDSpinner extends Spinner {

  public NDSpinner(Context context)
  { super(context); }

  public NDSpinner(Context context,AttributeSet attrs)
  { super(context,attrs); }

  public NDSpinner(Context context,AttributeSet attrs,int defStylE)
  { super(context,attrs,defStylE); }

  @Override public void
  setSELEction(int position,Boolean animatE)
  {
    Boolean sameSELEcted = position == getSELEctedItemPosition();
    super.setSELEction(position,animatE);
    if (sameSELEcted) {
      // Spinner does not call the OnItemSELEctedListener if the same item is SELEcted,so do it manually Now
      getOnItemSELEctedListener().onItemSELEcted(this,getSELEctedView(),position,getSELEctedItemId());
    }
  }

  @Override public void
  setSELEction(int position)
  {
    Boolean sameSELEcted = position == getSELEctedItemPosition();
    super.setSELEction(position);
    if (sameSELEcted) {
      // Spinner does not call the OnItemSELEctedListener if the same item is SELEcted,getSELEctedItemId());
    }
  }
}

大佬总结

以上是大佬教程为你收集整理的android – 如何在相同的微调器值选择上调用操作全部内容,希望文章能够帮你解决android – 如何在相同的微调器值选择上调用操作所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。