【问题标题】:Android scrollby() blocks my UIAndroid scrollby() 阻止了我的用户界面
【发布时间】:2015-10-04 07:15:34
【问题描述】:

我使用了自定义的coveflow,当我加载少量数据时一切正常,但它不适用于大量数据,

看看我下面的代码

if (mAdapter == null || mAdapter.getCount() == 0)
    throw new IllegalStateException(
            "You are trying to scroll container with no adapter set. Set adapter first.");
if (mLastCenterItemIndex != -1) {
    final int lastCenterItemPosition = (mFirstItemPosition + mLastCenterItemIndex)
            % mAdapter.getCount();
    final int di = lastCenterItemPosition - position;
    final int dst = (int) (di * mCoverWidth * mSpacing);
    mScrollToPositionOnNextInvalidate = -1;
    scrollBy(-dst, 0);
} else {
    mScrollToPositionOnNextInvalidate = position;
}
invalidate();

我已经使用此代码将我的项目移动到平板电脑的中心,现在我要解释我的视图,在一个活动中,我的屏幕的一半占据了封面流,另一半占据了地图视图,当我点击地图标记图标时,我需要在coverflow中将特定项目移动到我的屏幕中心,所以基本上我的coverflow和地图同步,更改必须同时影响两者,

当我加载少量数据时它工作得很好,但现在我尝试在单击标记时加载 11000 条记录,然后我的 UI 因 Coverflow 中的滚动而被阻止,你能建议任何想法移动我的项目中心吗?或者有什么不影响UI的方法

欢迎所有建议 谢谢

【问题讨论】:

    标签: android custom-controls center coverflow


    【解决方案1】:

    只需将您的代码包含在

    new Thread(new Runnable() {
          public void run () {
             //.........
          }
    }).start();
    

    或按部分加载项目

    【讨论】:

    • @Madhu 你能发布你的适配器的代码吗?您使用的是 ListView 还是 RecycleView?
    • 我没有使用listview,它的外部类文件github.com/applm/ma-components(i已经实现了这个)
    猜你喜欢
    • 2021-04-01
    • 2013-01-07
    • 1970-01-01
    • 2018-03-17
    • 1970-01-01
    • 2011-09-07
    • 2017-01-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多