带左右箭头的水平回收站视图指标
我正在尝试使用右箭头和左箭头指标实现水平回收视图。所以会发生的是,如果点击右箭头应该出现下一个项目,并且如果点击左箭头应该出现前一个项目,并且在列表的末端左箭头应该消失。我不知道如何实现这一点。有人可以帮我吗?以下是我的Horizontal Recyclerview适配器。带左右箭头的水平回收站视图指标
public class DialogRecyclerViewAdapter extends RecyclerView.Adapter<DialogRecyclerViewAdapter.ViewHolder> { Context context;
List<UploadImage> dataAdapters;
private SharedPreferences.Editor mSharedPrefEditor;
ImageLoader imageLoader;
public DialogRecyclerViewAdapter(List<UploadImage> getDataAdapter, Context context){
super();
this.dataAdapters = getDataAdapter;
this.context = context;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.cardview, parent, false);
ViewHolder viewHolder = new ViewHolder(view);
return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder Viewholder, int position) {
final UploadImage dataAdapterOBJ = dataAdapters.get(position);
imageLoader = ImageAdapter.getInstance(context).getImageLoader();
imageLoader.get(dataAdapterOBJ.getImage(),
ImageLoader.getImageListener(
Viewholder.VollyImageView,//Server Image
R.drawable.loading_1,//Before loading server image the default showing image.
android.R.drawable.ic_dialog_alert //Error image if requested image dose not found on server.
)
);
Viewholder.VollyImageView.setImageUrl(dataAdapterOBJ.getImage(), imageLoader);
Viewholder.ImageTitleTextView.setText(dataAdapterOBJ.getBrand_name());
Viewholder.garment_price.setText(dataAdapterOBJ.getGarment_price());
Viewholder.VollyImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(MihuChatApplication.getInstance().getContext());
mSharedPrefEditor = sharedPref.edit();
mSharedPrefEditor.putString(Constants.KEY_FROM_CHAT, "fromChatWIndow").apply();
Intent i=new Intent(MihuChatApplication.getInstance().getContext(), DetailsNewActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//PACK DATA TO SEND
i.putExtra("image_title",dataAdapterOBJ.getGarment_name());
i.putExtra("image_url",dataAdapterOBJ.getImage_full());
i.putExtra("desc_text", dataAdapterOBJ.getDesc_text());
//i.putExtra("image_url2", imageLarger);
i.putExtra("image_price", dataAdapterOBJ.getGarment_price());
//i.putExtra("disc_price", disc_price);
//open activity
MihuChatApplication.getInstance().getApplicationContext().startActivity(i);
}
});
}
@Override
public int getItemCount() {
return dataAdapters.size();
}
class ViewHolder extends RecyclerView.ViewHolder{
public TextView ImageTitleTextView, garment_price;
public NetworkImageView VollyImageView ;
public ViewHolder(View itemView) {
super(itemView);
garment_price = (TextView) itemView.findViewById(R.id.garment_price);
ImageTitleTextView = (TextView) itemView.findViewById(R.id.ImageNameTextView) ;
VollyImageView = (NetworkImageView) itemView.findViewById(R.id.VolleyImageView) ;
}
}
}
在此先感谢。
回答:
请尝试以下
这里img_LeftScroll是左侧的ImageView和img_right_scroll是水平列表之间的权利ImageView的,rv_horizontal是HorizontalList将视图
随后的onclick图像视图做以下,希望工程
img_LeftScroll.setOnClickListener(new View.OnClickListener() { @Override
public void onClick(View v) {
if (horizontalLayoutManagaer.findFirstVisibleItemPosition() > 0) {
rv_horizontal.smoothScrollToPosition(horizontalLayoutManagaer.findFirstVisibleItemPosition() - 1);
} else {
rv_horizontal.smoothScrollToPosition(0);
}
}
});
img_right_scroll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
rv_horizontal.smoothScrollToPosition(horizontalLayoutManagaer.findLastVisibleItemPosition() + 1);
}
});
以上是 带左右箭头的水平回收站视图指标 的全部内容, 来源链接: utcz.com/qa/261761.html