Use a class in another class

3

Good morning.

I'm new to Java, but come on.

I have a java class and need to use all of its methods in another main class.

There is a problem, I'm already using an extends in both classes.

I need to use all methods of this class (I put it in txt because it is large):

link

In this class:

public class SocialFragment extends Fragment {

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)  {
    return inflater.inflate(R.layout.social_layout,null);


}

}

Is there any way to do this without calling method by method?

@Edit

My MainActivity is my map with all business rules, I need to use it in one of them below.

But I'm having problems, since I'm already using the extends in the 2 classes.

    
asked by anonymous 04.12.2015 / 15:46

1 answer

2

In SocialFragment do:

MainActivity mainActivity = null;

@Override
public void onResume() {
     super.onResume();
     mainActivity = (MainActivity)getActivity();
}

@Override
public void onPause() {
    super.onPause();
    mainActivity = null;
}

Declare the methods you want to call as public in MainActivity and call them in SocialFragment like this:

if (mainActivity != null) {
    mainActivity.meuMetodo();
}
    
04.12.2015 / 16:21