Last active
August 29, 2015 14:17
-
-
Save dmitriy-chernysh/6d83d6af83e8afe2003b to your computer and use it in GitHub Desktop.
[Android] Alert dialog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SampleDialog extends DialogFragment { | |
@NonNull | |
@Override | |
public Dialog onCreateDialog(Bundle savedInstanceState) { | |
View view = getActivity().getLayoutInflater().inflate(R.layout..... , null); | |
return new AlertDialog.Builder(getActivity()) | |
.setView(view) | |
.setTitle(R.string.....) | |
.setPositiveButton(android.R.string.ok, null) | |
.create(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.support.v4.app.FragmentManager; | |
............... | |
public class SomeClass extends Fragment{ | |
private static final String DIALOG_TAG = "sometag"; | |
............. | |
//call the alert dialog | |
FragmentManager fm = getActivity().getSupportFragmentManager(); | |
SampleDialog dialog = new SampleDialog(); | |
dialog.show(fm, DIALOG_TAG); | |
.............. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment