Android listview behave differently on same kind o

2019-08-15 20:58发布

问题:

I'm fighting with a problem that is driving me crazy: I have a very simple ListView which scroll smoothly on a device and very luggy on another device that is almost 100% the same.

here you can find a video of the luggy scroll and here you can find a video of the (almost) smooth scrolling.

the slow scroll happens on a device with this specs, the smooth scroll happens on a device with this specs

here is the very basic code I used (obviously using ViewHolder pattern), how the hell can it be possible?? Please somebody help me!!!

public DealerAdapter(Context context, int skinLayoutResourceId, ArrayList<Dealer> items) {
        super(context, skinLayoutResourceId, items);
        _items = items;
        mContext = context;
        layout = skinLayoutResourceId;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        DealerViewHolder holder = null;
        // reuse views
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(layout, null);
            // configure view holder
            holder = new DealerViewHolder();
            holder.lblName = (TextView) convertView.findViewById(R.skinDealer.lblNameSurname);
            holder.lblSapCode = (TextView) convertView.findViewById(R.skinDealer.lblSapCode);
            holder.lblAddress = (TextView) convertView.findViewById(R.skinDealer.lblAddress);
            convertView.setTag(holder);
        } else
            holder = (DealerViewHolder) convertView.getTag();
        try {
            holder.lblName.setText(_items.get(position).getName());
            holder.lblCode.setText(_items.get(position).getCode());
            holder.lblAddress.setText(_items.get(position).getAddress());
        } catch (Exception e) {
            // TODO: handle exception
        }
        return convertView;
    }

    static class DealerViewHolder {
        TextView lblName;
        TextView lblAddress;
        TextView lblCode;
    }

EDIT:

I tested the same code on another samsung device, galaxy note 10.1, with the same OS version as the one having a smooth scrolling and with more powerfull hardware, the result is surprending!! Here is the behavior, here are the device's specs.

Some times android is a real giant question mark!!!!

EDIT 2:

Here is logcat while executing a scroll on the device with android 4.2.2

01-27 10:34:59.994: V/AlarmManager(2371): waitForAlarm result :8
01-27 10:35:00.004: D/KeyguardClockWidgetService(4910): onReceive action=android.intent.action.TIME_TICK
01-27 10:35:00.004: V/AlarmManager(2371): ClockReceiver onReceive() ACTION_TIME_TICK
01-27 10:35:00.034: D/IconMerger(2561): overflowShown = false
01-27 10:35:00.034: D/IconMerger(2561): moreRequired = false
01-27 10:35:00.094: I/WAKELOCK_RELEASE(2371): TIMESTAMP=3927849415108, TAG=AlarmManager, TYPE=PARTIAL_WAKE_LOCK             , COUNT=0, PID=2371, UID=1000
01-27 10:35:00.474: I/InputReader(2371): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.146 ] when=3598409874000
01-27 10:35:00.474: I/InputDispatcher(2371): Delivering touch to: action: 0x0
01-27 10:35:00.494: I/ThermalZone(2371): TEMP 41000 newMaxSensorState 0
01-27 10:35:00.504: I/CustomFrequencyManager(4461): newFrequencyRequest  - mFrequency = 800000, mTimeoutMs = -1, mPkgName = LIST_SCROLL_BOOSTER@3
01-27 10:35:00.504: I/CustomFrequencyManager(4461): Boost Request from package = LIST_SCROLL_BOOSTER@3 frequency : 800000type = 6
01-27 10:35:00.504: I/CustomFrequencyManager(4461): !! pkgName = LIST_SCROLL_BOOSTER@3
01-27 10:35:00.504: I/CustomFrequencyManager(4461): Request from package name pkgName = LIST_SCROLL_BOOSTER@3
01-27 10:35:00.504: I/CustomFrequencyManager(4461): mContext is Not Null  mContext.pkgName = com.reply.fasttrack
01-27 10:35:00.504: I/CustomFrequencyManager(4461): mToken is Null....Creating New Binder!
01-27 10:35:00.504: I/CustomFrequencyManager(4461): CPUDVFSControlRequest : doFrequencyRequest::  = 800000 Timeout : -1
01-27 10:35:00.504: I/power(2371): *** acquire_dvfs_lock : lockType : 1  freq : 800000 
01-27 10:35:00.504: D/CustomFrequencyManagerService(2371): acquireDVFSLockLocked : type : DVFS_MIN_LIMIT  frequency : 800000  uid : 10169  pid : 4461  pkgName : LIST_SCROLL_BOOSTER@3
01-27 10:35:00.614: I/InputReader(2371): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=] when=3598555846000
01-27 10:35:00.614: I/InputDispatcher(2371): Delivering touch to: action: 0x1
01-27 10:35:01.984: I/Monitor(2371): SIOP:: Current AP = 365, CP = 0
01-27 10:35:03.354: D/BatteryService(2371): update start
01-27 10:35:03.354: D/BatteryService(2371): level:21, scale:100, status:3, health:2, present:true, voltage: 3614, temperature: 319, technology: Li-ion, AC powered:false, USB powered:true, Wireless powered:false, icon:17303346, invalid charger:0, online:4, charge type:1, current avg:-368
01-27 10:35:03.354: D/BatteryService(2371): Sending ACTION_BATTERY_CHANGED.
01-27 10:35:03.364: D/STATUSBAR-BatteryController(2561): onReceive() - ACTION_BATTERY_CHANGED
01-27 10:35:03.364: D/STATUSBAR-BatteryController(2561): onReceive() - BATTERY_STATUS_DISCHARGING: tw_stat_sys_battery_usb_not_charge
01-27 10:35:03.364: D/STATUSBAR-PhoneStatusBar(2561):  mBrightnessEnablebySettings = true mBrightnessEnablebyBattery = true mBrightnessEnablebyDisableFlag = true
01-27 10:35:03.514: I/power(2371): *** release_dvfs_lock : lockType : 1 
01-27 10:35:03.514: D/CustomFrequencyManagerService(2371): releaseDVFSLockLocked : Getting Lock type frm List : DVFS_MIN_LIMIT  frequency : 800000  uid : 10169  pid : 4461  tag : LIST_SCROLL_BOOSTER@3

回答1:

The only difference that I see between the devices is the Android version. Android 4.4 introduces changes in order to make the whole system more smooth, even in low-memory devices.

Here you have more details: https://developer.android.com/about/versions/kitkat.html#svelte

It might not be very helpful, but if the version it's the only diference it might be that.



回答2:

After weeks of investigating, the reason was unbelievable: the problem was caused from a background image on the root of the layout containing the listview that was too big (almost 2MB). Although I know that using big images as background is not a good practice, I really do not understand why on an high performance device this was causing problem and on a less-performant device everything was running perfectly!

By the way I hope this will help anyone having my same problem