5

I am having tab host with three tabs.In the first tab i am doing some bitmap operations on a canvas(bit heavy). Whenever i move on to second or third tab,the activity in the tab goes blank.I have a edit text in tab 1,so when ever the soft keyboard pops up, the rest of tabs are working fine.I think it is because the window gets re-sized when soft keyboard pops up.I think if i am able to re-size or refresh the tab 1 i will be able to see the contents properly in rest of the tabs.Is there any way i can re-size the current window or refresh the window.I tried to set width and height using LayoutParams but it is not resizing actually.Also the tabs starts working properly when i change the orientation probably because the entire tab host is getting re-created. Is there any one who has faced similar problem?

Any help would be appreciated.

androidGuy
  • 5,553
  • 12
  • 39
  • 56

2 Answers2

3

You can automatically refresh the tab content at tab select with the FLAG_ACTIVITY_CLEAR_TOP option. So when you create the tabs just add it to your Tab spec.

tabHost.addTab(tabHost.newTabSpec("tab1")
                      .setIndicator("myTabName")
                      .setContent(new Intent(this, MyTabContent.class)
                      .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
Dyonisos
  • 3,541
  • 2
  • 22
  • 25
0

If you're using canvas inside an activity inside a tab, make sure your dimensions are always correct upon recreating the view - Log the values first and observe where and when the width and height acquire new values. most common error points are onDraw and onMeasure

josephus
  • 8,284
  • 1
  • 37
  • 57