In my app I start with an ActionBarActivity
that implements ActionBar.TabListener
. In my main activity, I have a ViewPager
that helps me navigate between 4 ListFragments
. Each ListFragment
calls a second ListFragment (ExpandableListView)
that replaces it when an item is clicked.
I have noticed that inside of my second ListFragment
, I am able to select one of the tabs and it updates the ViewPager/Tabs
, but only in the background. The visible fragment does not move, but when it is closed, you can see that the action did take place. Is there a way that I can update the view from this second ListFragment
, so that both swiping and selecting a tab will shift to one of the other 4 base fragments?
EDIT: Code that was actually requested.
@Override
public void onListItemClick(ListView lv, View view, int position,
long id)
{
super.onListItemClick(lv, view, position, id);
Cursor b = ((SimpleCursorAdapter) lv.getAdapter()).getCursor();
b.moveToPosition(position);
String numberHelper = b.getString(b.getColumnIndex("_id"));
int number = Integer.parseInt(numberHelper);
Cursor c = myDB.getRow(number, fragmentIdentifier);
String content;
Cursor parentCursor;
Cursor childCursor;
Cursor conditionsCursor;
Cursor blessingsCursor;
Cursor favoriteCursor;
Cursor favoriteHelperCursor;
switch ( fragmentIdentifierHelper )
{
// favorite
case 0:
content = c.getString(c.getColumnIndex(DataBaseHelper.KEY_BOOK));
parentCursor = myDB.getRowsFavorites(content);
childCursor = myDB.getRowsFavorites(content);
conditionsCursor = myDB.getRowsFavorites(content);
blessingsCursor = myDB.getRowsFavorites(content);
favoriteCursor = myDB.getRowsFavorites(content);
favoriteHelperCursor = myDB.getRowsFavorites(content);
break;
// condition
case 1:
content = c.getString(c.getColumnIndex(DataBaseHelper.KEY_CONDITION));
parentCursor = myDB.getRowsCondition(content);
childCursor = myDB.getRowsCondition(content);
conditionsCursor = myDB.getRowsCondition(content);
blessingsCursor = myDB.getRowsCondition(content);
favoriteCursor = myDB.getRowsCondition(content);
favoriteHelperCursor = myDB.getRowsCondition(content);
break;
// blessing
case 2:
content = c.getString(c.getColumnIndex(DataBaseHelper.KEY_BLESSING));
parentCursor = myDB.getRowsBlessing(content);
childCursor = myDB.getRowsBlessing(content);
conditionsCursor = myDB.getRowsBlessing(content);
blessingsCursor = myDB.getRowsBlessing(content);
favoriteCursor = myDB.getRowsBlessing(content);
favoriteHelperCursor = myDB.getRowsBlessing(content);
break;
// chronological
case 3:
content = c.getString(c.getColumnIndex(DataBaseHelper.KEY_BOOK));
parentCursor = myDB.getRowsBook(content);
childCursor = myDB.getRowsBook(content);
conditionsCursor = myDB.getRowsBook(content);
blessingsCursor = myDB.getRowsBook(content);
favoriteCursor = myDB.getRowsBook(content);
favoriteHelperCursor = myDB.getRowsBook(content);
break;
default:
content = null;
parentCursor = null;
childCursor = null;
conditionsCursor = null;
blessingsCursor = null;
favoriteCursor = null;
favoriteHelperCursor = null;
break;
}
c = null;
Fragment contentList = new FragmentContentList(parentListGetter(parentCursor),
childListGetter(childCursor), conditionsListGetter(conditionsCursor),
blessingsListGetter(blessingsCursor), favoriteGetter(favoriteCursor),
favoriteHelper(favoriteHelperCursor));
getFragmentManager().beginTransaction()
.addToBackStack(null)
.replace(android.R.id.content, contentList)
.commit();
}
Thanks.