Question

I'm within a fragment calling a subroutine from another class which contains getActionBar.removeTab() but as I'm within a fragment the method I'm calling needs to be static but getActionBar cannot be contained within a static method. Which leaves me a little out of my depth. Any ideas?

Purpose

The point of the below code is so within the fragment I can remove tabs when neccersy from the class OtherClass

Code:

public class Example extends Fragment{
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
OtherClass.SubWhichWontWork(); }


public class OtherClass extends FragmentActivity implements
ActionBar.TabListener {

public void SubWhichWontWork() throws ClientProtocolException, IOException {
if (blabla > other){
getActionBar().removeTabAt(numtabbar);}

}
Was it helpful?

Solution

Since OtherClass extends Activity and with assumption that Example fragment is used inside OtherClass you can use ((OtherClass)getActivity()).SubWhichWontWork(); inside onCreateView of Example class

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top