title: The scrolling speed of the GridView is slow as it is stopped
body: <p>In one fragment of my current application, there are three lists in a listview, and each list displays a GridView, with about eight to fifteen imageViews as items in the GridView. So I make adapter A and adapter B. Adapter A acts as a bridge between the ListView and the string representing the title of the ListView and each GridView. Adapter B connects the GridView with its ImageView(8~15). So, in the getView method of adapter A, I inserted code that created the adapter B and connect to the corresponding gridView. The reason for calling the adapter from within the adapter (and of course my personal guess) is that the data and images are well connected to the gridView, and even though it is well connected to the ListView, the scrolling speed of the GridView is slow as if the scrolling stopped. </p>
  
  <p>My question is</p>
  
  <p>1] I want to know why the scroll speed of gridView is slow as it is stopped.</p>
  
  <ul>
  <li>Personally, I do not think it's because of the size of the image. (This is because the scrolling speed of the GridView was exactly the same as it was before the image was entered into the image view.)</li>
  </ul>
  
  <p>2] What is the solution?</p>
  
  <ul>
  <li>I tried to load the image using AsyncTask. But my images are in a drawable folder (int variable) and I do not know how to load them (eg, int mimageResource = R.drawable.image) While attempting, the image will still have empty image items When the GridView is open, the speed of the GridView is similar at that time, so I wonder if AsyncTask is a solution.</li>
  </ul>
  
  <p>I would really appreciate your advice.</p>
  
  <p>---------------------------these are my code---------------------------------</p>
  
  <p>1] SiteAdapter.java(link gridview and item)</p>
  
  <pre><code>public class SiteAdapter extends ArrayAdapter&lt;Site&gt; {
  private Site currentSite;
  private final int REQUEST_WIDTH = 256;
  private final int REQUEST_HEIGHT = 256;
  public Context context;
  
  
  public SiteAdapter(Context context, ArrayList&lt;Site&gt; sites) {
      super(context, 0, sites);
      this.context = context;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      View listItemView = convertView;
      SiteViewHolder viewHolder;
      if(listItemView == null){
          listItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent,false);
  
          viewHolder = new SiteViewHolder();
          viewHolder.icon = (ImageView) listItemView.findViewById(R.id.image);
          viewHolder.icon_name = (TextView) listItemView.findViewById(R.id.name);
  
          listItemView.setTag(viewHolder);
      }
      else
          viewHolder = (SiteViewHolder) listItemView.getTag();
  
      currentSite = getItem(position);
      viewHolder.position = position;
  
      //new ThumbnailTask(position, viewHolder).execute((currentSite.getMsite_imagesource()));
  
      BitmapFactory.Options options = new BitmapFactory.Options();
      options.inJustDecodeBounds = true;
      BitmapFactory.decodeResource(getContext().getResources(),currentSite.getMsite_imagesource(),options);
      options.inSampleSize = setSimpleSize(options, REQUEST_WIDTH, REQUEST_HEIGHT);
      options.inJustDecodeBounds = false;
      Bitmap bitmap = BitmapFactory.decodeResource(getContext().getResources(),currentSite.getMsite_imagesource(),options);
  
  
      viewHolder.icon.setBackground(new ShapeDrawable(new OvalShape()));
      viewHolder.icon.setClipToOutline(true);
      viewHolder.icon.setImageBitmap(bitmap);
      viewHolder.icon_name.setText(currentSite.getMsite_name());
  
  
      return listItemView;
  }
  private int setSimpleSize(BitmapFactory.Options options, int requestWidth, int requestHeight){
      int originalWidth = options.outWidth;
      int originalHeight = options.outHeight;
  
      int size = 1;
  
      while(requestWidth &lt; originalWidth || requestHeight &lt; originalHeight){
          originalWidth = originalWidth / 2;
          originalHeight = originalHeight / 2;
  
          size = size * 2;
      }
      return size;
  }
  </code></pre>
  
  <p>2] ListAdapter (link list_title(String), GridView to ListView)</p>
  
  <pre><code>public class ListAdapter extends BaseAdapter {
  
  public Context mcontext;
  public Hashtable&lt;String, ArrayList&lt;Site&gt;&gt; mdata;
  public Map.Entry&lt;String,ArrayList&lt;Site&gt;&gt; copyData;
  public ArrayList&lt;String&gt; keySet = new ArrayList&lt;String&gt;();
  private String key;
  private int num=0;
  public String currentName;
  private ArrayList&lt;Site&gt; currentSite;
  private int [] count = {0,0,0};
  
  public ListAdapter(Context context,Hashtable&lt;String, ArrayList&lt;Site&gt;&gt; data){
      mcontext = context;
      mdata = data;
      Iterator it = data.entrySet().iterator();
      while(it.hasNext()) {
          copyData = (Map.Entry&lt;String, ArrayList&lt;Site&gt;&gt;) it.next();
          keySet.add(copyData.getKey());
      }
  }
  
  public String getKey(int position){
      //Iterator it = mdata.entrySet().iterator();
      //copyData = (Map.Entry&lt;String, ArrayList&lt;Site&gt;&gt;) it.next();
      return keySet.get(position);
  }
  
  @Override
  public int getCount() {
      /*Iterator it = mdata.entrySet().iterator();
      while(it.hasNext())
      {
          num++;
      }
      return num;*/
      return keySet.size();
  }
  
  @Override
  public ArrayList&lt;Site&gt; getItem(int position) {
      return mdata.get(keySet.get(position));
  }
  
  @Override
  public long getItemId(int position) {
      return position;
  }
  
  @Override
  public View getView(final int position, final View convertView, final ViewGroup parent) {
      View view = convertView;
      final ArrayList&lt;Site&gt; currentSite;
      ListViewHolder holder;
  
      if(view == null) {
          view = LayoutInflater.from(mcontext).inflate(R.layout.site_list, parent, false);
  
          holder = new ListViewHolder();
          holder.list_title = (TextView) view.findViewById(R.id.title_site_list);
          holder.lists = (GridView) view.findViewById(R.id.gridView);
  
          view.setTag(holder);
      }
  
      else
          holder = (ListViewHolder) view.getTag();
  
      currentName = keySet.get(position);
      holder.list_title.setText(currentName);
  
      currentSite = getItem(position);
  
      final SiteAdapter siteAdapter = new SiteAdapter(mcontext,currentSite);
      holder.lists.setAdapter(siteAdapter);
  
      final ViewSwitcher viewSwitcher = (ViewSwitcher) view.findViewById(R.id.visibility);
      holder.list_title.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              if(count[position]%2==0){
                  viewSwitcher.setVisibility(View.VISIBLE);
                  viewSwitcher.showNext();
                  count[position]++;
              }
              else if(count[position]%2==1){
                  viewSwitcher.setVisibility(View.GONE);
                  viewSwitcher.showNext();
                  count[position]++;
              }
          }
      });
  
      holder.lists.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int position, long id) {
              final Site site = currentSite.get(position);
              if (site.getMsite_name() == "Gist home") {
                  PopupMenu popupIFWB = new PopupMenu(mcontext.getApplicationContext(), view);
  
                  popupIFWB.getMenuInflater().inflate(R.menu.insta_facebook_web_blog_popup_menu, popupIFWB.getMenu());
                  popupIFWB.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                      @Override
                      public boolean onMenuItemClick(MenuItem menuItem) {
                          switch (menuItem.getItemId()) {
                              case R.id.webIFWB:
                                  openWebPage(site.getMsite_urlW());
                                  break;
                              case R.id.blogIFWB:
                                  openWebPage(site.getMsite_urlB());
                                  break;
                              case R.id.facebookIFWB:
                                  openWebPage(site.getMsite_urlF());
                                  break;
                              case R.id.instaIFWB:
                                  openWebPage(site.getMsite_urlI());
                                  break;
                          }
                          return false;
                      }
                  });
                  popupIFWB.show();
              } else
                  openWebPage(site.getMsite_url());
          }
  
      });
      return view;
  }
  
  private static class ListViewHolder{
      public TextView list_title;
      public GridView lists;
  }
  
  public void openWebPage(String url){
      Uri webpage = Uri.parse(url);
      Intent siteMove = new Intent(Intent.ACTION_VIEW, webpage);
      if(siteMove.resolveActivity(mcontext.getPackageManager()) != null)
          mcontext.startActivity(siteMove);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>3] OfficialFragment.java(same as home)</p>
  
  <pre><code>public class OfficialFragment extends Fragment {
  
  
  private int count = 0;
  private ArrayList&lt;String&gt; arrayGroup = new ArrayList&lt;String&gt;();
  private Hashtable&lt;String, ArrayList&lt;Site&gt;&gt; arrayChild = new Hashtable&lt;String, ArrayList&lt;Site&gt;&gt;();
  
  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
      final View viewMain = inflater.inflate(R.layout.listview, null);
      super.onCreate(savedInstanceState);
      ListView listView = (ListView) viewMain.findViewById(R.id.listView);
  
      //GridView gridView = (GridView) viewMain.findViewById(R.id.gridView);
      setArrayData();
  
      ListAdapter listAdapter = new ListAdapter(getActivity(),arrayChild);
      listView.setAdapter(listAdapter);
  
      return viewMain;
  }
  
  public void openWebPage(String url){
      Uri webpage = Uri.parse(url);
      Intent siteMove = new Intent(Intent.ACTION_VIEW, webpage);
      if(siteMove.resolveActivity(getActivity().getPackageManager()) != null)
          startActivity(siteMove);
  }
  
  public void setArrayData(){
  
      arrayGroup.add("공식 사이트 모음");
      arrayGroup.add("조직 사이트 모음");
      arrayGroup.add("동아리 사이트 모음");
  
      ArrayList&lt;Site&gt; arrayOfficial = new ArrayList&lt;Site&gt;();
      arrayOfficial.add(new Site("Gist home", "https://www.gist.ac.kr/kr/","https://blog.naver.com/gist1993","https://www.facebook.com/GIST.ac.kr/","https://www.instagram.com/gist1993/", R.drawable.ic_dashboard_black_24dp));
      arrayOfficial.add(new Site("Zeus system", "https://zeus.gist.ac.kr", R.drawable.ic_dashboard_black_24dp));
      arrayOfficial.add(new Site("Portal system", "https://portal.gist.ac.kr/intro.jsp", R.drawable.ic_dashboard_black_24dp));
      arrayOfficial.add(new Site("Email system", "https://mail.gist.ac.kr/loginl?locale=ko_KR", R.drawable.ic_dashboard_black_24dp));
      arrayOfficial.add(new Site("Gist college", "https://college.gist.ac.kr/", R.drawable.ic_dashboard_black_24dp));
      arrayOfficial.add(new Site("Gist library", "https://library.gist.ac.kr/", R.drawable.ic_dashboard_black_24dp));
      arrayOfficial.add(new Site("학내공지", "https://college.gist.ac.kr/main/Sub040203", R.drawable.ic_dashboard_black_24dp));
      arrayOfficial.add(new Site("GIST 창업진흥센터", "https://www.facebook.com/gistbi/?ref=py_c", R.drawable.ic_dashboard_black_24dp));
      arrayOfficial.add(new Site("전기전자컴퓨터공학부", "http://eecs.gist.ac.kr/", R.drawable.ic_dashboard_black_24dp));
      arrayOfficial.add(new Site("신소재공학부", "http://mse.gist.ac.kr", R.drawable.ic_dashboard_black_24dp));
      arrayOfficial.add(new Site("기계공학부", "http://me.gist.ac.kr", R.drawable.ic_dashboard_black_24dp));
      arrayOfficial.add(new Site("지구·환경공학부", "http://env1.gist.ac.kr", R.drawable.ic_dashboard_black_24dp));
      arrayOfficial.add(new Site("생명과학부", "http://life1.gist.ac.kr", R.drawable.ic_dashboard_black_24dp));
      arrayOfficial.add(new Site("물리·광과학과", "http://phys.gist.ac.kr/", R.drawable.ic_dashboard_black_24dp));
      arrayOfficial.add(new Site("화학과", "http://chem.gist.ac.kr", R.drawable.ic_dashboard_black_24dp));
      arrayOfficial.add(new Site("융합기술원", "http://iit.gist.ac.kr", R.drawable.ic_dashboard_black_24dp));
      arrayOfficial.add(new Site("나노바이오재료전자공학과", "http://wcu.gist.ac.kr/", R.drawable.ic_dashboard_black_24dp));
  
      ArrayList&lt;Site&gt; arrayOrganization = new ArrayList&lt;Site&gt;();
      arrayOrganization.add(new Site("Gist 총학생회", "https://www.facebook.com/gistunion/", R.drawable.gistunion));
      arrayOrganization.add(new Site("Gist 동아리연합회", "https://www.facebook.com/gistclubunite/", R.drawable.clubnight));
      arrayOrganization.add(new Site("Gist 하우스", "https://www.facebook.com/GISTcollegeHOUSE/", R.drawable.gisthouse));
      arrayOrganization.add(new Site("Gist 문화행사위원회", "https://www.facebook.com/Moonhangwe/", R.drawable.moonhangwe));
      arrayOrganization.add(new Site("Gist 신문","http://gistnews.co.kr/", "https://www.facebook.com/pg/GistSinmoon/posts/", R.drawable.gistnews));
      arrayOrganization.add(new Site("Gist 홍보대사", "http://blog.naver.com/PostList.nhn?blogId=gist1993&amp;from=postList&amp;categoryNo=28", R.drawable.gionnare));
  
      ArrayList&lt;Site&gt; arrayCircle = new ArrayList&lt;Site&gt;();
      arrayCircle.add(new Site("영화 동아리 Cinergy", "https://www.facebook.com/gistcinergy/", R.drawable.cinergy));
      arrayCircle.add(new Site("영상편집 동아리 The Gist", "https://www.facebook.com/Gentletist/","https://www.youtube.com/channel/UCMUDHS0SZvQilFe5h6eI9rA/videos", R.drawable.thegist));
      arrayCircle.add(new Site("문예창작 동아리 사각사각", "https://www.facebook.com/GIST-%EC%82%AC%EA%B0%81%EC%82%AC%EA%B0%81-238788459851229/", R.drawable.sagaksagak));
      arrayCircle.add(new Site("gist 고양이 지냥이", "https://www.facebook.com/giscats/", R.drawable.giscat));
      arrayCircle.add(new Site("요리동아리 이쑤시개", "https://www.facebook.com/%EC%9D%B4%EC%91%A4%EC%8B%9C%EA%B0%9C-%EC%9A%94%EB%A6%AC%ED%95%98%EB%8A%94-GIST%EC%83%9D-272551203239747/?ref=py_c", R.drawable.essosigae));
      arrayCircle.add(new Site("칵테일 동아리 MixoloGIST", "https://www.facebook.com/Mixologist-1584231725157207", R.drawable.mixologist));
      arrayCircle.add(new Site("보드게임 동아리 BGM", "https://www.facebook.com/GISTBGM", R.drawable.bgm));
      arrayCircle.add(new Site("성소수자 모임 speQtrum", "https://www.facebook.com/gistspeqtrum/", R.drawable.speqtrum));
      arrayCircle.add(new Site("만화 동아리 erutlucbus", "https://www.facebook.com/Erutlucbus/", R.drawable.eru));
      arrayCircle.add(new Site("천체관측 동아리 SpaceBar", "https://www.facebook.com/GISTspacebar/", R.drawable.spacebar));
      arrayCircle.add(new Site("전산 동아리 WING", "https://www.facebook.com/GISTWING/", R.drawable.wing));
      arrayCircle.add(new Site("환경 동아리 온새미로", "https://www.facebook.com/onsaemiro123/", R.drawable.onsaemiro));
      arrayCircle.add(new Site("축구 동아리 Kickass", "https://www.facebook.com/gistkickass/?ref=br_rs", R.drawable.kickass));
  
      arrayChild.put(arrayGroup.get(0),arrayOfficial);
      arrayChild.put(arrayGroup.get(1),arrayOrganization);
      arrayChild.put(arrayGroup.get(2),arrayCircle);
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>4] SiteHolder.java(ViewHolder contain item of GridView)</p>
  
  <pre><code>public class SiteViewHolder {
  public ImageView icon;
  public TextView icon_name;
  public int position;
  }
  </code></pre>