我正在解决让我发疯的问题: 我有一个非常简单的ListView,它可以在一台设备上平滑滚动,而且在另一台几乎100%相同的设备上非常有用。
here你可以找到一个luggy卷轴的视频,here你可以找到(几乎)平滑滚动的视频。
在具有this规格的设备上进行慢速滚动,在具有this规格的设备上进行平滑滚动
这里是我使用的非常基本的代码(显然使用ViewHolder模式),它怎么可能?请有人帮助我!!!
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;
}
编辑:
我在另一个三星设备上测试了相同的代码,galaxy note 10.1,与具有平滑滚动和更强大硬件的操作系统版本相同,结果是过度扩展!! Here是行为,here是设备的规格。
有时候android是一个真正的巨型问号!!!!
编辑2:
这是使用android 4.2.2在设备上执行滚动时的logcat
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
答案 0 :(得分:0)
我在设备之间看到的唯一区别是Android版本。 Android 4.4引入了更改,以使整个系统更加流畅,即使在低内存设备中也是如此。
您有更多详情: https://developer.android.com/about/versions/kitkat.html#svelte
它可能不是很有帮助,但是如果版本是唯一不同的可能是它。
答案 1 :(得分:0)
经过数周的调查,原因令人难以置信:问题是由布局根目录上的背景图片引起的,其中列表视图太大(差不多2MB)。虽然我知道使用大图像作为背景并不是一个好习惯,但我真的不明白为什么在高性能设备上这会导致问题,而在性能较差的设备上,一切都运行得很好!
顺便说一句,我希望这可以帮助任何有同样问题的人