我在某些Android设备中遇到Spinner的问题:我点击了一个项目,但是微调器位置没有改变。
我在Galaxy S2(4.0.3 API 15)和Avvio中文设备(4.0.4 API 15)上看到过这个问题。每个日志的日志行为都有所不同,如下所示:
Avvio:
I/InputDispatcher(234): channel '41c8acc8 PopupWindow:418f39c8 (server)' ~ abortBrokenDispatchCycle - notify=false
Galaxy S2:
I/InputDispatcher(1995): Delivering touch to current input target: action: 1, channel 'xxxx'
这是我的xml
配置:
<Spinner
android:id="@+id/status_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="0dip"
android:paddingLeft="5dp"
android:layout_marginBottom="5dp" />
和(剥离的)代码:
Spinner status_spinner;
protected void onCreate(Bundle savedInstanceState) {
status_spinner = (Spinner)findViewById(R.id.status_spinner);
status_spinner.setOnItemSelectedListener(new OnItemSelectedListener(){
public void onItemSelected(AdapterView<?> arg0, View view, int position, long id) {
Log.d(TAG, "Selected status code " + position);
}
public void onNothingSelected(AdapterView<?> adapter){
Log.d(TAG, "Nothing selected");
}
});
}
在这些消息之后没有任何反应,没有事件被触发。我得到了第一个微调器事件,即在微调器初始化时触发的事件并选择第一个项目,但之后不再有。
这适用于其他设备,从API级别8到最新设备。我真的坚持这个,任何线索?
已解决:微调器包含在LinearLayout
设置为android:animateLayoutChanges
的{{1}}中。将其更改为true
解决了问题。