Creating an About Dialog Box for Android

There exists hundreds of tutorials about creating pop up dialog boxes or creating custom dialog boxes and frankly I found a lot of those tutorials hard to follow or they crashed the app. Personally, I never needed a dialog box to do more than just show the About the app to app information like version, contact credentials, developer/company, logo, etc. This tutorial should very easy to follow and simple to understand, I made it so that the code used is easily manageable and reusable. Also small in size. I used Java in my implementation as I found it more manageable and clear to implement rather than using XML.

To create an About dialog box, first its required to import the following for this tutorial:

  • import android.text.method.LinkMovementMethod;
  • import android.text.util.Linkify;
  • import android.widget.TextView;
  • import android.content.DialogInterface;
  • import;
  • import;


/*call this method for any button or menu that will open this window*/

public void AboutWindow()

        AlertDialog.Builder aboutWindow = new AlertDialog.Builder(this);//creates a new instance of a dialog box
        final String website = "";
        final String AboutDialogMessage = " AppName Version 1.0\n By Developer\n Website for contact:\n";
        final TextView tx = new TextView(this);//we create a textview to store the dialog text/contents
        tx.setText(AboutDialogMessage + website);//we set the text/contents
        tx.setAutoLinkMask(RESULT_OK);//to linkify any website or email links
        tx.setTextColor(Color.BLACK);//setting the text color
        tx.setTextSize(15);//setting the text size
        //again to enable any website urls or email addresses to be clickable links
        Linkify.addLinks(tx, Linkify.WEB_URLS);

        aboutWindow.setIcon(R.drawable.ic_launcher);//to show the icon next to the title "About"
        aboutWindow.setTitle("About");//set the title of the about box to say "About"
    	aboutWindow.setView(tx);//set the textview on the dialog box

    	aboutWindow.setPositiveButton("OK", new DialogInterface.OnClickListener()//creates the OK button of the dialog box

			public void onClick(DialogInterface dialog, int which)
				dialog.dismiss();//when the OK button is clicked, dismiss() is called to close it
    	});;//this method call will bring up the dialog box when the user calls the AboutDialog() method


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s