滚动列表视图中的微调器值更改,例如,如果我从旋转器的第一个位置选择“不正常”,然后向下滚动并返回到顶部,则微调器值自动出现在零位置意味着正常。这是我的Adapter类,列表视图中的数据是动态的(变化的)。
以下代码:
public CustomAdapter(Context context, int resource,
ArrayList<CustomerDetails> objects) {
super(context, resource, objects);
vi = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Resource = resource;
list = objects;
}
public View getView(final int modelPosition, View convertView,
ViewGroup parent) {
View v = convertView;
if (v == null) {
holder = new ViewHolder();
v = vi.inflate(Resource, null);
java.util.List<String> options = new java.util.ArrayList<String>();
options.add("Ok");
options.add("Not Ok");
options.add("Not Recieved");
holder.spinner1 = (Spinner) v.findViewById(R.id.spinner1);
holder.name = (TextView) v.findViewById(R.id.name);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
getContext(), android.R.layout.simple_spinner_item,
options);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
holder.spinner1.setAdapter(adapter);
if (myMap.containsKey(modelPosition)) {
holder.spinner1.setSelection(myMap.get(modelPosition));
}
holder.spinner1.setTag(modelPosition);
holder.spinner1
.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent,
View view, int position, long id) {
myMap.put(modelPosition, position);
if (position == 1) {
Status_fos = parent.getItemAtPosition(
position).toString();
db.updateMobileStatus(mobile_fos,
Status_fos);
}
if (position == 2) {
Status_fos = parent.getItemAtPosition(
position).toString();
db.updateMobileStatus(mobile_fos,
Status_fos);
}
if (position == 3) {
Status_fos = parent.getItemAtPosition(
position).toString();
db.updateMobileStatus(mobile_fos,
Status_fos);
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
});
v.setTag(holder);
} else {
holder = (ViewHolder) v.getTag();
}
holder.name.setText(list.get(modelPosition).getMobile());
mobile_fos = list.get(modelPosition)
.getMobile();
return v;
}
class ViewHolder {
public Spinner spinner1;
public TextView name;
public TextView cid;
}
}