title: Android removes previous tab icon, when I create new one dynamically
body: <p>I create <code>TabItems</code> dynamically, and I assign the new tab created an icon, but the problem is: when I create another tab 'again' dynamically, the previous <code>TabItem</code> icons just disappears! Why?</p>
  <p>Here is the picture when I haven't created a new tab dynamically:</p>
  <p><a href="https://drive.google.com/file/d/1C80e-Yldlu6asL2H_vCIbwH7cY7Farpn/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1C80e-Yldlu6asL2H_vCIbwH7cY7Farpn/view?usp=sharing</a></p>
  <p>and here is the image when I create another one with icon:</p>
  <p><a href="https://drive.google.com/file/d/1i-IXudvYayLf9mGhBGQmyCkjeVkN3xXs/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1i-IXudvYayLf9mGhBGQmyCkjeVkN3xXs/view?usp=sharing</a></p>
  <p>you can see the difference.</p>
  <p>the code to create first three dynamic <code>tabitems</code> with their icons is as follows:</p>
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main_page_drawer);
          this.tabLayout = findViewById(R.id.tab_layout);
          this.viewPager = findViewById(R.id.view_pager);
          tabLayout.setupWithViewPager(viewPager);
          SetUpViewPager(viewPager);
          this.toolbar = findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
          NavigationView navigationView = findViewById(R.id.navigation_view);
          navigationView.setItemIconTintList(null);
          tabLayout.setupWithViewPager(viewPager);
          tabLayout.getTabAt(0).setIcon(R.drawable.lock);
          tabLayout.getTabAt(1).setIcon(R.drawable.contacts);
          tabLayout.getTabAt(2).setIcon(R.drawable.info);
  </code></pre>
  <p>here is my code for creating new <code>TabItems</code> in <code>TabLayout</code></p>
  <pre><code>public void create_user_detail_tab(UserObject userObject) {
          MyViewPagerAdapter Adapter = new MyViewPagerAdapter(getSupportFragmentManager());
          UserDetailFragment userDetailFragment = new UserDetailFragment();
          // the code for AddFragmentPage would be in the next session, I'll paste it's function for you
          Adapter.AddFragmentPage(userDetailFragment,userObject.getName());
          byte[] decodedString = Base64.decode(userObject.getImage(),Base64.NO_WRAP);
          InputStream inputStream  = new ByteArrayInputStream(decodedString);
          Bitmap bitmap  = BitmapFactory.decodeStream(inputStream);
          Bitmap circleBitmap = CircleBitmapConverter.makeCircle(bitmap);
          Drawable d = new BitmapDrawable(getResources(), circleBitmap);
          tabLayout.getTabAt(tabs_number).setIcon(d);
          // tabs_number is number of tabs which are not changing not dynamic
          TabLayout.Tab tab = tabLayout.getTabAt(tabs_number);
          tab.select();
          // I increase the number of tabs present each time a new one is created ( pretty logical )
          tabs_number++;
      }
  </code></pre>
  <p>and this is the AddFragmentPage ( which I said in previous code I will include its code for you, if necessary :</p>
  <pre><code>public void AddFragmentPage(Fragment frag,String title) {
              addToFragments(frag);
              addToFragmentsTitle(title);
              MyViewPagerAdapter myViewPagerAdapter = new MyViewPagerAdapter(getSupportFragmentManager());
              myViewPagerAdapter.notifyDataSetChanged();
              viewPager.setAdapter(myViewPagerAdapter);
          }
  </code></pre>