I'm using a FragmentActivity with a FragmentTabHost created dinamically. I want to refresh the fragment hosted in the current tab by clicking an item in the action bar.
This is the code in the FragmentActivity that creats the Tabs and the Fragments:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_halls);
[...]
while (iteratorHalls.hasNext()) {
hallFragment = new HallFragment();
bundle = new Bundle();
bundle.putString("Code", hallTmp.getCode());
TabSpec tabspec=mTabHost.newTabSpec("hall_" + i);
tabspec.setIndicator(hallTmp.getDescription());
mTabHost.addTab(tabspec, hallFragment.getClass(), bundle);
hallFragment.setArguments(bundle);
i++;
}
[...]
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_refresh:
// HERE I WANT TO REFRESH MY CURRENT FRAGMENT
return true;
default:
return super.onOptionsItemSelected(item);
}