Tab host activity is empty

I have a tab with three tabs. On the first tab, I do some raster operations on the canvas (bit heavy). Whenever I go to the second or third tab, the activity on the tab is empty. I have the edit text on tab 1, so when the popup keyboard appears, the rest of the tabs work fine. I think this is because the window gets the size when the soft keyboard appears. I think that if I can resize or refresh tab 1, I can correctly see the contents in the other tabs. Is there a way to resize the current window or update the window. I tried setting the width and height using LayoutParams, but it does not actually resize. Also, the tabs start working properly when I change the orientation, probably because the entire tab node is recreated.Is there anyone faced with a similar problem?

Any help would be greatly appreciated.

+5
source share
2 answers

You can automatically update the contents of a tab when you select a tab using the option FLAG_ACTIVITY_CLEAR_TOP. Therefore, when you create tabs, just add them to the tab specification.

tabHost.addTab(tabHost.newTabSpec("tab1")
                      .setIndicator("myTabName")
                      .setContent(new Intent(this, MyTabContent.class)
                      .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
+3
source

If you use canvas inside an action inside a tab, make sure your dimensions are always correct when you recreate the view. First write down the values ​​and see where and when the width and height take on new values. the most common error points are onDraw and onMeasure

0
source

All Articles