I am trying to create an Android application with two tabs, one for the textField / and TreeMenu buttons (where each element has a checkbox associated with it), and the other for the list. I also use ActionBarSherlock. I have already successfully written the program in one main action, but itβs hard for me to figure out how to split this initial action to fit the two new fragments that I need to create for each tab. Moreover, every time an element is added to the first tab (regardless of whether it is disabled or added to textField), the list in the second window should recognize the update.
To create an action bar, I can do this ...
ActionBar actionbar = getSupportActionBar(); actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionbar.setTitle("AppName");
To create tabs ..
ActionBar.Tab Frag1Tab = actionbar.newTab().setText("InputTab"); ActionBar.Tab Frag2Tab = actionbar.newTab().setText("ListTab");
To create fragments and their listeners, the basis of each tab ...
Fragment Fragment1 = new Fragment_1(); Fragment Fragment2 = new Fragment_2(); Frag1Tab.setTabListener(new MyTabsListener(Fragment1)); Frag2Tab.setTabListener(new MyTabsListener(Fragment2));
To add them to the action bar ...
actionbar.addTab(Frag1Tab); actionbar.addTab(Frag2Tab);
All this appears in my MainActivity. For example, I want the ArrayList variable to be available for both fragments, so, as I said, I can update the list. I would love to hear any help you can provide. I would be interested to see how the Otto API can work for something like this, but I'm not picky!
source share