我正在開發一個應用程序,使用expandableListView,一個自定義適配器。問題是每個項目調用getChildView多次。例如對於一個孩子的團體,該方法被稱爲9次。android:在ExpandableListView中的getChildView被稱爲每個項目9次
我不知道附什麼樣的代碼,我會附上getChildView(),在評論中寫的,如果你需要一個又一個
@Override
public View getChildView(int groupPosition, int childPosition, boolean b, View convertView, ViewGroup viewGroup) {
Vehicle vehicle = (Vehicle) getChild(groupPosition, childPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) fragment.getActivity()
.getSystemService(fragment.getActivity().LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.child_item, null);
}
TextView tv = (TextView) convertView.findViewById(R.id.country_name);
ImageView iv = (ImageView) convertView.findViewById(R.id.flag);
tv.setText(vehicle.getUname().toString());
//TODO load image
return convertView;
}
任何幫助將aprreciated
這就好。如果您正確使用視圖回收,那麼這會損害性能 –