I have a question about dialogfragment - I created a class with dialogfragment by tutorial, but in the tutorial, the dialogfragment was shown by button click - I want to show dialogfragment by clicking on fragment tab in my MainActivity - I can't figure out how.. I have Fragment GetItem method, where i have empty case 4 in my code - It's the fragment, where I want to open dialogfragment by clicking on it. there are my codes. Thanks for all help and answers! Sorry if something isn't clear..
-Problem is fixed (viz comments) - I created new DialogFragment - xml file and java class - codes from guides.codepath.com/android/Using-DialogFragment#build-dialog and then I added this codes to MainActivity
tabLayout.setOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager) {
@Override
public void onTabSelected(TabLayout.Tab tab) {
super.onTabSelected(tab);
int position = tab.getPosition();
if (position == 4) {
showAlertDialog();
}
}
});
}
private void showAlertDialog() {
FragmentManager fm = getSupportFragmentManager();
EditNameDialogFragment alertDialog = EditNameDialogFragment.newInstance("Some title");
alertDialog.show(fm, "fragment_alert");
}