我正在使用自定义arrayadapter。
我想说:“好的,在这个位置不要创建项目。”
以下是代码:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
super.getView(position,convertView,parent);
View itemView = convertView;
// Make sure we have a view to work with
if (itemView == null) {
itemView = getActivity().getLayoutInflater().inflate(R.layout.item_critere, parent, false);
}
// Find the car to work with
Criteria currentCriteria = mCriteria.get(position);
// Fill the view
((TextView) itemView.findViewById(R.id.critere_title)).setText(currentCriteria.getName());
String text;
if (currentCriteria.isNumber()) {
text = currentCriteria.getIntValue() + " " + currentCriteria.getUnity();
} else {
// get Selected values in a String[]
String[] resultTab = currentCriteria.getTabTextValue();
text = new String();
//Convert String[] in String
int i = 0;
for (i = 0; i < resultTab.length; i++) {
if (i != 0)
text += ", ";
text += resultTab[i];
}
}
((TextView) itemView.findViewById(R.id.critere_value)).setText(text);
return itemView;
}
}
我正在考虑管理调用getView()的方法,但我不知道是哪一个。
提前致谢:)