diff --git a/opentasks/src/main/java/org/dmfs/tasks/TaskListActivity.java b/opentasks/src/main/java/org/dmfs/tasks/TaskListActivity.java index d00963542..6d1da9024 100644 --- a/opentasks/src/main/java/org/dmfs/tasks/TaskListActivity.java +++ b/opentasks/src/main/java/org/dmfs/tasks/TaskListActivity.java @@ -267,12 +267,7 @@ protected void onCreate(Bundle savedInstanceState) // Bind the tabs to the ViewPager mTabs = (TabLayout) findViewById(R.id.tabs); mTabs.setupWithViewPager(mViewPager); - - // set up the tab icons - for (int i = 0, count = mPagerAdapter.getCount(); i < count; ++i) - { - mTabs.getTabAt(i).setIcon(mPagerAdapter.getTabIcon(i)); - } + setupTabIcons(); mViewPager.addOnPageChangeListener(new OnPageChangeListener() { @@ -347,6 +342,15 @@ public void onClick(View v) } + private void setupTabIcons() + { + for (int i = 0, count = mPagerAdapter.getCount(); i < count; ++i) + { + mTabs.getTabAt(i).setIcon(mPagerAdapter.getTabIcon(i)); + } + } + + @Override protected void onResume() { @@ -528,6 +532,11 @@ public void onActivityResult(int requestCode, int resultCode, Intent intent) Uri newTaskUri = intent.getData(); displayIntent.setData(newTaskUri); onNewIntent(displayIntent); + + /* Icons have to be refreshed here because of some bug in ViewPager-TabLayout which causes them to disappear. + See https://github.com/dmfs/opentasks/issues/643 + and https://stackoverflow.com/questions/42209046/tablayout-icons-disappear-after-viewpager-refresh */ + setupTabIcons(); } }