I am working on one of my Android projects, trying to reduce the code inside my actions. In one of them, I have a CustomView (which only extends LinearLayout), which opens the DialogFrament dialog box when clicked. Now I implement this by overriding onTouch() in action and subsequently opening DialogFrament. It looks something like this:
@Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { if (v.getId() == mCustomView.Id()) { mDialogFragment.show(mFragmentManager, "");
I would like to move the process of opening DialogFragment away from the action and to CustomView itself, but the problem is that I cannot get an instance of FragmentManager (using getSupportFragmentManager() ) in CustomView. Am I planning, or should I stick with the code that I am working on? I do this, so my code looks more comprehensible and understandable.
source share