当前位置:首页 > Android

Sipnner点击相同Item不响应的解决方法

jsc10年前 (2016-04-06)Android4050

Spinner,两次点击同一个item的时候,第二次会不响应OnItemSelect事件。

解决方法:

@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3) 
{
    //do what you want
    ......
    //after you do
    /*here items is the adapter's items*/
    int size = items.size();
    Spinner spinner = (Spinner)arg1.getParent();
    spinner.setSelection(size); 
}

也就是说:只要在选择处理完成之后,主动设置选中的item的index >= adapter的个数就行了。

下次点击相同的item的时候,就会响应了。

当然,这里有个问题:就是选择之后显示的文字不对。这里你需要保存一下你当前选择的文字的。

或者重写一个adapter,重写里面的getView方法。


扫描二维码推送至手机访问。

版权声明:本文由微小站发布,如需转载请注明出处。

本文链接:https://jsc0.com/post/68.html

分享给朋友:

“Sipnner点击相同Item不响应的解决方法” 的相关文章

TypedArray和obtainStyledAttributes使用

TypedArray和obtainStyledAttributes使用

在编写Android自定义按钮示例基础上,如果要指定字体大小产生这样的效果: 其实是不需要自定义变量的,可以直接使用......…

Android应用加入微信分享

Android应用加入微信分享

一、申请你的AppIDhttp://open.weixin.qq.com/  友情提示:推荐使用eclipse打包软件最后一步的MD5值去申请AppID二、官网下载libammsdk.jar包http://open.weixin.qq.com/download/?lang=zh_…

修改keystore密码别名等

修改keystore密码别名等

之前在测试Eclipse ADT的Custom debug ˂a target="_blank" title="View all posts in keystore" hr…

Android中的消息通知(NotificationManager和Notification)

下面来谈谈notification,这个notification一般用在电话,短信,邮件,闹钟铃声,在手机的状态栏上就会出现一个小图标,提 示用户处理这个通知,这时手从上方滑动状态栏就可以展开并处理这个快讯。已添加的Notification.Builder,使其更容易构建通知。 notifica…

GridView中item高度自适应

item高度自适应public class MyAdapter extends BaseAdapter {         GridView mGv;&n…

采用SharedPreferences保存用户偏好设置参数

采用SharedPreferences保存用户偏好设置参数-------------------------------------------------1.eclipse就是通过xml来保存用户的偏好设置-->window-->perfences-------------------…