I created an Activity with a custom footer that has 4 buttons.
Code for onClick footers:
@Override
public void onClick(View v)
{
try
{
switch (v.getId())
{
case R.id.button1:
getSupportFragmentManager()
.beginTransaction()
.addToBackStack(null)
.replace(R.id.flcontent,Tab1)
.commit();
break;
case R.id.button2:
getSupportFragmentManager()
.beginTransaction()
.addToBackStack(null)
.replace(R.id.flcontent,Tab2)
.commit();
break;
case R.id.button3:
getSupportFragmentManager()
.beginTransaction()
.addToBackStack(null)
.replace(R.id.flcontent, Tab3)
.commit();
break;
case R.id.button4:
getSupportFragmentManager()
.beginTransaction()
.addToBackStack(null)
.replace(R.id.flcontent, Tab4)
.commit();
break;
}
} catch (Exception e)
{
e.printStackTrace();
}
}
In the onCreate method for tabs, I make a call to the server to retrieve the list. Different tabs have different requests.
When I press button 2, Tab2 loads and so on to Button4, Tab4
For example, when I move from Tab1 to Tab2: When I press Button2, Tab1 is replaced by Tab2, and a new list is loaded. When I press Button1 back, how can I prevent the server from being called again in Tab1?
source
share