Commit e4fc47a8 authored by shexiaoheng's avatar shexiaoheng

fixed event bug

parent 29f599e1
...@@ -14,6 +14,9 @@ import java.util.Arrays; ...@@ -14,6 +14,9 @@ import java.util.Arrays;
/** /**
* Created by heng on 16/9/6. * Created by heng on 16/9/6.
*
* Edited by heng on 16/10/09:
* 修复滚动后返回值错误的bug
*/ */
public class PickerViewAlone extends LinearLayout { public class PickerViewAlone extends LinearLayout {
...@@ -22,8 +25,6 @@ public class PickerViewAlone extends LinearLayout { ...@@ -22,8 +25,6 @@ public class PickerViewAlone extends LinearLayout {
private OnSelectedListener onSelectedListener; private OnSelectedListener onSelectedListener;
private int position;
public PickerViewAlone(Context context) { public PickerViewAlone(Context context) {
super(context); super(context);
init(context); init(context);
...@@ -43,13 +44,13 @@ public class PickerViewAlone extends LinearLayout { ...@@ -43,13 +44,13 @@ public class PickerViewAlone extends LinearLayout {
this.onSelectedListener = listener; this.onSelectedListener = listener;
} }
public void setPickerData(ReadableArray array, final ArrayList<String> curSelectedList){ public void setPickerData(ReadableArray array, final ArrayList<String> curSelectedList) {
switch (array.getType(0).name()){ switch (array.getType(0).name()) {
case "Array": case "Array":
setMultipleData(array,curSelectedList); setMultipleData(array, curSelectedList);
break; break;
default: default:
setAloneData(array,curSelectedList); setAloneData(array, curSelectedList);
break; break;
} }
} }
...@@ -105,17 +106,14 @@ public class PickerViewAlone extends LinearLayout { ...@@ -105,17 +106,14 @@ public class PickerViewAlone extends LinearLayout {
@Override @Override
public void onItemSelected(String item, int index) { public void onItemSelected(String item, int index) {
int viewCount = pickerViewAloneLayout.getChildCount(); int viewCount = pickerViewAloneLayout.getChildCount();
for (int j = 0; j < viewCount; j++) { for (int k = 0; k < viewCount; k++) {
View view = pickerViewAloneLayout.getChildAt(j); View view = pickerViewAloneLayout.getChildAt(k);
if (view instanceof LoopView) { if (view instanceof LoopView) {
LoopView loop = (LoopView) view; LoopView loop = (LoopView) view;
if (loop.getTag() == loopView.getTag()) { selectedItems[k] = loop.getSelectedItem();
position = j;
break;
}
} }
} }
selectedItems[position] = item;
if (onSelectedListener != null) { if (onSelectedListener != null) {
for (int i = 0; i < selectedItems.length; i++) { for (int i = 0; i < selectedItems.length; i++) {
curSelectedList.set(i, selectedItems[i]); curSelectedList.set(i, selectedItems[i]);
...@@ -169,7 +167,7 @@ public class PickerViewAlone extends LinearLayout { ...@@ -169,7 +167,7 @@ public class PickerViewAlone extends LinearLayout {
} }
} }
public int getViewHeight(){ public int getViewHeight() {
int viewHeight = 0; int viewHeight = 0;
View view = pickerViewAloneLayout.getChildAt(0); View view = pickerViewAloneLayout.getChildAt(0);
if (view instanceof LoopView) { if (view instanceof LoopView) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment