我用一些数据填充了一个微调器,如下所示:
adapter =
newSpinAdapter(this,com.Orange.R.layout.spinnerrowlist,spinnerInfo); adapter.setDropDownViewResource(com.Orange.R.layout.multiline_spinner_dropdown_item);
previousVisitCommentsSpinner.setAdapter(adapter);
public class UserComments {
public String coach;
public String comment;
public String date;
public UserComments(String coach, String comment, String date) {
this.coach = coach;
this.comment = comment;
this.date = date;
}
}
public class SpinAdapter extends ArrayAdapter<UserComments>{
private Context context;
private ArrayList<UserComments> spinnerInfo;
public SpinAdapter(Context context, int textViewResourceId, ArrayList<UserComments> spinnerInfo){
super(context, textViewResourceId, spinnerInfo);
this.spinnerInfo = spinnerInfo;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.spinnerrowlist, null);
}
Visit.UserComments info = spinnerInfo.get(position);
if (info != null) {
TextView spinneritem1 = (TextView) v.findViewById(R.id.textview_spinner1);
TextView spinneritem2 = (TextView) v.findViewById(R.id.textview_spinner2);
TextView spinneritem3 = (TextView) v.findViewById(R.id.textview_spinner3);
if (spinneritem1 != null) {
spinneritem1.setText(info.coach);
spinneritem1.setTextColor(getResources().getColor(
R.color.medium_gray));
}
if (spinneritem2 != null) {
spinneritem2.setText(info.comment);
spinneritem2.setTextColor(getResources().getColor(
R.color.medium_gray));
}
if (spinneritem3 != null) {
spinneritem3.setText(info.date);
spinneritem3.setTextColor(getResources().getColor(
R.color.medium_gray));
}
}
return v;
}
}
还行吧。
显示的数据与未选中时的状态不同!!!!选择时应显示的数据应为:2012-09-03 second 11
。谁能告诉我哪里出错了???什么是解决方案。谢谢