M
M
moved_on2015-02-20 04:56:52
Java
moved_on, 2015-02-20 04:56:52

How to solve display problems of listview items?

Hello.
Problem 1: listview caches the display of items. That is - we see the first 20 elements on the screen. By scrolling down, the listview takes the display of the first items, thus getting a list like 1-2-3-4-5-1-2-3-4-5-1-2-3-4-5-... Tried list. setScrollingCacheEnabled(false), android:scrollingCache="false" doesn't help. How to decide?
Problem 2: Fragments of AB. Fragment A contains elements with images downloaded from the server. Images are cached. We go to fragment B. We return to fragment A. The list remains, but the images are "reinstalled", it seems that the process of downloading them from the server or from the cache starts again. A flicker-like effect is created. How to decide?
Thank you for your time.
In Supplement - GetView Adapter for Problem 1:

@Override
    public View getView(int position, View convertView, ViewGroup parent) {

        MiniHolder viewHolder = null;
        final Brand listViewItem = objects.get(position);
        TextView name;

        if (convertView==null)
        {
            convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_bmg, null);
            name=(TextView)convertView.findViewById(R.id.bmgvalue);
            viewHolder=new MiniHolder(null,name,null);
            viewHolder.getBmg().setText(listViewItem.getBrand());
            convertView.setTag(viewHolder);
        }
        else
        {
            viewHolder = (MiniHolder) convertView.getTag();
        }
        return convertView;
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
anyd3v, 2015-02-20
@moved_on

At least it is not clear why viewHolder.getBmg().setText(listViewItem.getBrand()); with convertView==null. In the if (convertView==null) branch, only the ViewHolder should be filled, and the viewHolder.getBmg().setText(...) code should be executed in any case, since if convertView!=null the old data will remain in the View.
About pictures, what do you use? Bitmaps actually weigh a lot in memory and take time to decode them. Try https://github.com/nostra13/Android-Universal-Imag... instead of inventing bicycles

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question