I have an page with arrows, by clicking on each arrow I move to next page with grid and images there (the images were downloaded before entering to the page).
I have an performance issue that at the beginning before I run over all the collection of pages and load the images into the memory the page change is made slowly because of the images load. I wanted to ask if you have any ideas how to fix it:
So I have an PageAdapter
that extends FragmentStatePagerAdapter
. There I'm creating a page
that extends BaseFragment
and in every page
I create instance of GridAdapter
that extends BaseAdapter
and responsible for the images drawing in the GridView
. I don't work directly with the GridAdapter
because I need to return to FragmentStatePagerAdapter
an fragment
for the paging.
When I creating GridAdapter
for each page I create the viewHolder
:
private MyViewHolders createHolder() {
MyViewHolders holder = new MyViewHolders();
View view = LayoutInflater.from(fragment.getActivity())
.inflate(R.layout.cust_layout, null);
holder.layout = (RelativeLayout) view.findViewById(R.id.Rlayout);
holder.image = (ImageView) view.findViewById(R.id.mainIMage);
return holder;
}
and In getView
public View getView(int position, View convertView, ViewGroup parent) {
CarData carD = getCarItem(position);
MyViewHolders viewHolder = getViewHolder (carD.id);
viewHolder.carImage.setImageDrawable(carD.image);
convertView = viewHolder.layout;
return convertView;
}
It all loads with 1 sec delay, after I browsed all the pages it start to work correctly.
0 comments:
Post a Comment