Tengo una app que contiene un ViewPager
con sus 3 Tabs. Al pasar de la primera a la segunda lo hace normal, pero ya de la segunda a la tercera se pone un poco lenta cabe resaltar que en la tercera tengo una galería de imágenes que no son tan pesadas con un peso de 40.4K
aproximado por el tema de la resolución, no sé por qué se pone lenta, pero es como si en el momento de desplazarse se crea de nuevo toda la galería, Gracias.
Acá esta el código del tab2
RecyclerView recyclerView;
RecyclerView.Adapter adapter;
RecyclerView.LayoutManager layoutManager;
View contentView;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
contentView = inflater.inflate(R.layout.fragment_dos, null);
return contentView;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
recyclerView = (RecyclerView) contentView.findViewById(R.id.reyclerViewDos);
layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
adapter = new AdapterClase();
recyclerView.setAdapter(adapter);
}
}
este es su recycler
introducir el código aquí
public class AdapterClase extends RecyclerView.Adapter {
private static final int[] MIS_IMAGENES= new int[]{R.drawable.cold1, R.drawable.cold2};
private static final String[] MIS_CANCIONES = new String[]{"Mylo Xyloto", "A Head Full of Dreams"};
public class ViewHolderClase extends RecyclerView.ViewHolder {
TextView banda, cancion;
ImageView imageView;
public ViewHolderClase(View itemView) {
super(itemView);
imageView = (ImageView) itemView.findViewById(R.id.imagenes);
cancion = (TextView) itemView.findViewById(R.id.musica);
}
}
@Override
public ViewHolderClase onCreateViewHolder(ViewGroup parent, int viewType) {
View viewItem = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_item, null);
return new ViewHolderClase(viewItem);
}
@Override
public void onBindViewHolder(ViewHolderClase holder, int position) {
holder.imageView.setBackgroundResource(MIS_IMAGENES[position]);
holder.cancion.setText(MIS_CANCIONES[position]);
}
@Override
public int getItemCount() {
return MIS_CANCIONES.length;
}
}
bueno este es del tab 3 precisamente
RecyclerView recyclerView;
RecyclerView.Adapter adapter;
RecyclerView.LayoutManager layoutManager;
View contentView;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
contentView = inflater.inflate(R.layout.fragment_tres, null);
return contentView;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
recyclerView = (RecyclerView) contentView.findViewById(R.id.reyclerViewTres);
layoutManager = new GridLayoutManager(getActivity(), 2);
recyclerView.setLayoutManager(layoutManager);
adapter = new AdapterAlbum();
recyclerView.setAdapter(adapter);
}
@Override
public void onClick(View v) {
}
} y este su recycler
private static final int[] MIS_IMAGENES = new int[]{R.drawable.cold22, R.drawable.cover3, R.drawable.cover};
public class ViewHolderClase extends RecyclerView.ViewHolder {
ImageView imageView;
public ViewHolderClase(View itemView) {
imageView = (ImageView) itemView.findViewById(R.id.cover);
}
}
@Override
public ViewHolderClase onCreateViewHolder(ViewGroup parent, int viewType) {
View viewItem = LayoutInflater.from(parent.getContext()).inflate(R.layout.album, null);
return new ViewHolderClase(viewItem);
}
@Override
public void onBindViewHolder(final ViewHolderClase holder, int position) {
holder.imageView.setBackgroundResource(MIS_IMAGENES[position]);
@Override
public int getItemCount() {
return MIS_IMAGENES.length;
}
}