my application just crashes whenever it tries to run the alertdialog. I'm not to sure the proper way to do these but what I am doing is, creating a Java Class called 'AboutActivity' which contains the method 'popup()' ideally to create the AlertDialog. In my main activity I am creating the object and calling the method.
'popup()' in AboutActivity:
public class AboutActivity extends DialogFragment
{
public void popup()
{
new AlertDialog.Builder(getActivity())
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle("About Us")
.setMessage("Blah Blah Blah")
.setCancelable(true)
.setPositiveButton("Ok", null)
.show();
}
}
Main activity:
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()){
case R.id.nav_About:{
AboutActivity about = new AboutActivity();
about.popup();
}
}