我怎样才能在Android的微调得到一个事件时,当前所选的项目再次选择? [英] How can I get an event in Android Spinner when the current selected item is selected again?

查看:75
本文介绍了我怎样才能在Android的微调得到一个事件时,当前所选的项目再次选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个setOnItemSelectedListener何时微调项目更改微调回应。我的要求是,当我再次点击当前所选的项目,敬酒应该显示。如何让这一事件?在当前选定的项目再次点击,微调没有响应。 `

  StorageSpinner.setOnItemSelectedListener(新AdapterView.OnItemSelectedListener(){

        @覆盖
        公共无效onItemSelected(适配器视图适配器,视图V,INT I,长期LNG){
            Toast.makeText(getApplicationContext(),(CharSequence中)StorageSpinner.getSelectedItem(),Toast.LENGTH_SHORT).show();

        }

        @覆盖
        公共无效onNothingSelected(适配器视图为arg0){
            Toast.makeText(getApplicationContext(),没有选择,Toast.LENGTH_SHORT).show();

        }
    });
 

解决方案

当你再次点击当前选择的项目的话,就不会触发任何事件。所以,你不能赶上setOnItemSelectedListener的微调做出回应。

I have written an setOnItemSelectedListener for spinner to respond when the spinner item is changed. My requirement is when I clicks again the currently selected item, a toast should display. How to get this event? When the currently selected item is clicked again, spinner is not responding. `

    StorageSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){

        @Override
        public void onItemSelected(AdapterView adapter, View v, int i, long lng) {              
            Toast.makeText(getApplicationContext(), (CharSequence) StorageSpinner.getSelectedItem(), Toast.LENGTH_SHORT).show();

        }

        @Override
        public void onNothingSelected(AdapterView arg0) {
            Toast.makeText(getApplicationContext(), "Nothing selected", Toast.LENGTH_SHORT).show();

        }
    });  

解决方案

When you clicks again the currently selected item, then it can not fire any event. So you can not catch setOnItemSelectedListener for spinner to respond.

这篇关于我怎样才能在Android的微调得到一个事件时,当前所选的项目再次选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆