我有這樣的RecyclerView。我希望它只顯示最多8點。但是在ArrayList中有更多8個換頁器。
我想當我站在8時,我將頁面更改爲9,顯示號碼的第8個點是9?它會更改爲10,11 ...
這是我的適配器
public RecyclerViewAdapter(Context context, int layout, int number, int viewpagerposition){
this.context = context;
this.layout = layout;
this.number = number;
this.viewpagerposition = viewpagerposition;
this.numberpage = numberpage;
}
@Override
public RecyclerViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(layout, parent, false);
RecyclerViewAdapter.ViewHolder viewHolder = new RecyclerViewAdapter.ViewHolder(view);
return viewHolder;
}
@Override
public void onBindViewHolder(RecyclerViewAdapter.ViewHolder holder, int position) {
if(position == viewpagerposition){
holder.itemView.setScaleX(1f);
holder.itemView.setScaleY(1f);
holder.txtrvPager.setText((position+1)+"");
holder.txtrvPager.setBackgroundResource(R.drawable.rvpager_activity);
}
else{
holder.itemView.setScaleX(0.5f);
holder.itemView.setScaleY(0.5f);
holder.txtrvPager.setBackgroundResource(R.drawable.rvpager_inactivity);
}
if(viewpagerposition > 8){
}
}
@Override
public int getItemCount() {
if(number > 8){
return 8;
}else{
return number;
}
}
public class ViewHolder extends RecyclerView.ViewHolder {
TextView txtrvPager;
public ViewHolder(View itemView) {
super(itemView);
txtrvPager = (TextView) itemView.findViewById(R.id.txtrvPager);
}
}
爲什麼不使用視圖尋呼機它更適合這個?示例庫https://github.com/ongakuer/CircleIndicator – Redman
你想分頁8,每個前8個傳呼機然後第8個傳呼機對嗎? – Vij
@Vij他只想要任意頁數的最多8個點 –