当前位置:  开发笔记 > 编程语言 > 正文

关于水平循环器视图中的ProperScrolling

如何解决《关于水平循环器视图中的ProperScrolling》经验,为你挑选了0个好方法。

我有问题在水平回收视图中滚动.例如,如果我有10个项目,第一次,我能够滚动到最后一项,但如果我去第一项,然后再次滚动到最后一项,它不会移动到最后一项.

这个问题是否与滚动有关,如果是这种情况,我是否应该覆盖滚动.

这是我的片段类声明

      LinearLayoutManager layoutManager
            = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
    mRecyclerView = (RecyclerView)v. findViewById(R.id.recycler_view);
    adapter  = new MyRecyclerAdapter(getActivity());
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setAdapter(adapter);

并在我的适配器中

public class MyRecyclerAdapter extends RecyclerView.Adapter {

private Context mContext;
JobSiteActivity mjobSiteActivity;
ImageLoader loader = null;

public MyRecyclerAdapter(Activity activity) {
    this.mContext = activity;
    mjobSiteActivity = (JobSiteActivity)activity;
    loader = mjobSiteActivity.getImageLoader();
}

@Override
public CustomViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
    View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.image_detail_fragment, null);

    CustomViewHolder viewHolder = new CustomViewHolder(view);
    return viewHolder;
}

@Override
public void onBindViewHolder(CustomViewHolder customViewHolder, int i) {
    //FeedItem feedItem = feedItemList.get(i);

    //Download image using picasso library
  /*  Picasso.with(mContext).load(feedItem.getThumbnail())
            .error(R.drawable.placeholder)
            .placeholder(R.drawable.placeholder)
            .into(customViewHolder.imageView);*/

    customViewHolder.imageView.setImageUrl(Images.imageThumbUrls[i], loader);
    customViewHolder.imageView.setOnClickListener(clickListener);
    customViewHolder.imageView.setTag(customViewHolder);


    //Setting text view title

}

@Override
public int getItemCount() {
    //return (null != feedItemList ? feedItemList.size() : 0);
    return  Images.imageThumbUrls.length;
}

public class CustomViewHolder extends RecyclerView.ViewHolder {
    protected NetworkImageView imageView;


    public CustomViewHolder(View view) {
        super(view);
        this.imageView = (NetworkImageView) view.findViewById(R.id.imageView);

    }
}


View.OnClickListener clickListener = new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        CustomViewHolder holder = (CustomViewHolder) view.getTag();
        int position = holder.getLayoutPosition();
        int position1 = holder.getAdapterPosition();
        Toast.makeText(mContext, "layoutPs"+position+"adapPos"+position, Toast.LENGTH_SHORT).show();
    }
};

}

我正在尝试使用V17 leanback附带的水平网格视图,它也扩展了recycleView,但我仍然面临着类似的问题,

如果我尝试在运行时将任何项目添加到回收器视图中,例如在拍照时,它也没有被添加,它分配空间并且它是空的?在这个问题上很难理解或调试.

推荐阅读
coco2冰冰
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有