Прокрутка галереи делает недействительным весь вид

1

У меня есть галерея в моем макете вместе с 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;
    }
  • 0
    Разместите свой код, используемый в адаптере для галереи. Возможно, вы не правильно используете вид
  • 0
    с аналогичной проблемой, но это выглядит как ошибка вне памяти, так как Галерея по какой-то причине не может освободить память, когда есть прокрутка (или просмотр текста можно прокручивать). В компоненте Gallery есть известная ошибка, которая вообще не допускает повторного использования представления адаптера (convertView всегда равен null)
Теги:
android-layout
android-ui

1 ответ

0

Вероятно, вам стоит посмотреть учебник для адаптеров и ConvertView.

Ещё вопросы

Сообщество Overcoder
Наверх
Меню