Прокрутка галереи делает недействительным весь вид
У меня есть Галерея в моем макете вместе с ImageView и несколькими виджетами TextView. К сожалению, у меня низкая производительность прокрутки для галереи на медленных телефонах. Проблема исчезает, когда я удаляю фоновое изображение из LinearLayout, содержащего ImageView и TextView. Я переопределил onDraw() для всего представления и проверил прямоугольник клипа - это всегда весь экран. Похоже, что каждый раз, когда я прокручиваю галерею (и она становится недействительной), весь экран становится недействительным. Есть ли способ избежать перерисовки во весь экран, когда я прокручиваю только виджет Галерея?
Спасибо
private class GalleryAdapter extends ArrayAdapter<WeatherDisplayInfo> {
LayoutInflater mInflater;
Context mContext;
public GalleryAdapter(Context context) {
super(context, R.layout.gallery_item_view, mForecastData);
mContext = context;
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return mForecastData.size();
}
public WeatherDisplayInfo getItem(int position) {
return mForecastData.get(position);
}
public long getItemId(int position) {
return position;
}
private class ViewHolder {
public TextView text_date;
public TextView text_forecast;
public TextView text_temperature;
public TextView text_pressure;
public TextView text_humidity;
public TextView text_windspeed;
public ImageView weather_image;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if(convertView == null) {
if(position == getCount() - 1) {
convertView = mInflater.inflate(R.layout.logo_view, null);
holder = new ViewHolder();
// store view holder
convertView.setTag(holder);
} else {
convertView = mInflater.inflate(R.layout.gallery_item_view, null);
holder = new ViewHolder();
holder.text_date = (TextView) convertView.findViewById(R.id.text_date);
holder.text_forecast = (TextView) convertView.findViewById(R.id.text_desc);
holder.text_temperature = (TextView) convertView.findViewById(R.id.text_temp);
holder.text_pressure = (TextView) convertView.findViewById(R.id.text_pressure);
holder.text_humidity = (TextView) convertView.findViewById(R.id.text_humidity);
holder.text_windspeed = (TextView) convertView.findViewById(R.id.text_wind);
holder.weather_image = (ImageView) convertView.findViewById(R.id.image_weather_view);;
// store view holder
convertView.setTag(holder);
convertView.setDrawingCacheEnabled(true);
convertView.buildDrawingCache();
}
} else {
holder = (ViewHolder) convertView.getTag();
}
// set view data
return convertView;
}
1 ответ
Вам, вероятно, стоит взглянуть на учебник по адаптерам и ConvertView.