Excude me if this is a dumb question.
I have a "Fragment" outer-class with and inner-class interface. This interface is only implemented by one other Activity-class using "implements OuterFragment.ParentActivityListener".
I would like to have a few constants to use with the interface methods. But these constants also needs to be available in the outer-class. Is there a way to access them from the outer-class as shown below? Is this a bad pattern to use, even though there will be a very limited use of this interface (=1)?
public class OuterFragment extends Fragment {
public interface ParentActivityListener {
public int OKBUTTON = 5;
public void onPlayertimerMessage(int idFromFragment, int idFromPosition, int iAction);
}
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
// Access interface constant from here?
}
}
Any input appreciated!
If it's a constant, it should be static and final :
public static final int OKBUTTON = 5;
And you access it with OuterFragment.ParentActivityListener.OKBUTTON
.