0
微調值上滾動列表視圖的變化,例如,如果我選擇不在第一位置,從我的微調OK,然後向下滾動,回到頂部,微調微調數值變化值自動在零位置意味着在OK。這裏是我的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;
}
}
插入圖像並刪除了一些空行 – lokusking