I had this weird scenario where every time I select a value from the spinner in the ListView
's 1st Item, the last ListView's
item its spinner value is the same as the first item. This will only happen when the total number of ListView items is 5 and above. I commented out the codes and retain just the declarations and it's still happening. Is this a bug in Android?
Clarifications:
My ListView's
Scroll Listener
is emptyMy spinner's
setOnItemSelectedListener
is commented out.Android SDK Tool version is 22.6.2
Android SDK Platform-Tools is 19.0.1
Here's the adapter code:
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
Viewholder v = new Viewholder();
v.rowView = convertView;
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (v.rowView == null) {
v.rowView = inflater.inflate(R.layout.inner_base_header_cutom, parent, false);
v.spinner = (Spinner) v.rowView.findViewById(R.id.spinner1);
v.rowView.setTag(v);
} else {
v = (Viewholder) v.rowView.getTag();
}
return v.rowView;
}
ViewHolder:
class Viewholder{
View rowView;
TextView itemPID;
TextView itemPrice;
TextView itemItemId;
Spinner spinner;
TextView subtotal;
}
XML:
<Spinner
android:id="@+id/spinner1"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_margin="20dip"
android:entries="@array/quanitiy"
android:layout_alignTop="@+id/itemPrice"
android:layout_toRightOf="@+id/imageDisplay" />
Array:
<string-array name="quanitiy">
<item>Quantity</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
<item>10</item>
</string-array>
UPDATE
I commented out the code for OnItemClickListner
. I updated the code above, still the problem exists. The only thing left is the declarations.
Scenario:
If I select 1
at the first item of the spinner [index 0] of the ListView
, the last item of ListView
's spinner gets also 1
without interaction. When down the listview's items until the last part, that's where I found out that they are both the same. I commented out the codes and just retained the declarations.