1

In my app layout I need to have dropdown list button on the top of the screen followed by a tabHost with four tabs, each tab shows different activities.

enter image description here

and on clicking the Button(Phys) shows you this:

enter image description here

Now what I want is that the tabcontent changes or updates itself according to the selected subject in the dropdown list.

What I am using is a simple tabactivity.

I want to know any good approach to get this function. Any body who had worked on similar thing Please help me .I desperately need this?

Navdroid
  • 4,453
  • 7
  • 29
  • 47

2 Answers2

2

the simple way:

  • provide a global static variable such as gCurrentActivity or gSomeValue,
  • on every activity set gCurrentActivity, so always you have current activity and that's context
  • in many situation you can use getApplicationContext()
  • write a method to refresh tab host or other controls after loading any activity or important events

with this simple way you can always update footer, header, tabs and etc.

Behnam
  • 2,212
  • 2
  • 22
  • 32
0

use a single activity for each tab say, you have 4 tabs say A, B, C, D, E so Have Five Actiities for each tab AAct, BAct, CAct, DAct, EAct, I assume each activity have n type of contents, say AaActivity, AbActivity, AcActivity....

have 5 arrays of Class type in a global class

class[] Arr_A = new class[]{AaaCT.class, AvAct.class....}; .......

have 1 flag of integer type in a global class, representing index of content in arrays of activities. say index initialized with 0;

now in onResume method of your activity AAct, BAct, CAct, write...

AAct:

onResume()
{
     Intent intent=new Intent(this, ArrA[index]);
     startActivity(intnet);

}
jeet
  • 29,001
  • 6
  • 52
  • 53