Spinner 不响应setOnItemSelectedListener事件

媒体盒子 2013-10-08 03:41:16
各位大神,此问题折磨了我一天了,求支招!
情况如下:
我在ViewFlow (一个开源的滚动页面框架,类似Viewpage)中加入了一个Spinner控件
spnSYDK = (Spinner)findViewById(R.id.spn_test1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, strChannelNumber);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spnSYDK.setAdapter(adapter);
spnSYDK.setOnItemSelectedListener(new Spinner.OnItemSelectedListener(){
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
/* 将所选mySpinner 的值带入myTextView 中*/
Log.d("test","onItemSelected arg2 = " + arg2);
}
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
Log.d("test","onNothingSelected ");
}
});

但是无论我选择Spinner里面的哪一项都不触发onItemSelected事件,也就无法实现选择功能 该page的布局如下
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:descendantFocusability="blocksDescendants"
android:layout_width="fill_parent" android:orientation="vertical" android:weightSum="1">
<TextView android:textAppearance="?android:attr/textAppearanceLarge" android:text="Sample Text" android:id="@+id/textView1" android:layout_gravity="top" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="center_horizontal"></TextView>
<Spinner android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/spn_test1"/>
<ListView android:id="@+id/listView1" android:layout_width="fill_parent" android:layout_height="fill_parent"></ListView>

</LinearLayout>

有用过ViewFlow 并且在里面使用过Spinner的同学支下招,我目前怀疑是ViewFlow把事件截取了。。。实在不行就得弃用ViewFlow了
...全文
879 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
下雨天很郁闷 2015-05-20
  • 打赏
  • 举报
回复
同求答案啊,楼主解决了吗?
专业的码农 2014-05-15
  • 打赏
  • 举报
回复
jghjkghj
媒体盒子 2013-10-09
  • 打赏
  • 举报
回复
没有人遇到过这种问题吗?
tracy891110 2013-10-09
  • 打赏
  • 举报
回复
换个思维。。。。。。
媒体盒子 2013-10-08
  • 打赏
  • 举报
回复
引用 3 楼 tantahe 的回复:
github上也有人提了这个问题
哎。。。那里也没有正确的回复
tantahe 2013-10-08
  • 打赏
  • 举报
回复
github上也有人提了这个问题
tantahe 2013-10-08
  • 打赏
  • 举报
回复
继承ViewFlow的setOnItemSelectedListener,在这里打印log,试试看。
媒体盒子 2013-10-08
  • 打赏
  • 举报
回复
android:descendantFocusability="blocksDescendants" 加不加没有关系

80,472

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧