I create `TabItems` dynamically, and I assign the new tab created an icon, but the problem is: when I create another tab 'again' dynamically, the previous `TabItem` icons just disappears! Why?

Here is the picture when I haven't created a new tab dynamically:

<https://drive.google.com/file/d/1C80e-Yldlu6asL2H_vCIbwH7cY7Farpn/view?usp=sharing>

and here is the image when I create another one with icon:

<https://drive.google.com/file/d/1i-IXudvYayLf9mGhBGQmyCkjeVkN3xXs/view?usp=sharing>

you can see the difference.

the code to create first three dynamic `tabitems` with their icons is as follows:

```
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);

```

here is my code for creating new `TabItems` in `TabLayout`

```
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++;
    }

```

and this is the AddFragmentPage ( which I said in previous code I will include its code for you, if necessary :

```
public void AddFragmentPage(Fragment frag,String title) {
            addToFragments(frag);
            addToFragmentsTitle(title);
            MyViewPagerAdapter myViewPagerAdapter = new MyViewPagerAdapter(getSupportFragmentManager());
            myViewPagerAdapter.notifyDataSetChanged();
            viewPager.setAdapter(myViewPagerAdapter);
        }

```