Android Open Source - modern-art-ui More Information Dialog






From Project

Back to project page modern-art-ui.

License

The source code is released under:

MIT License

If you think the Android project modern-art-ui listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package course.lab.modernartui.dialogs;
//w w  w  . j  a v a 2s  . co m
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

import course.lab.modernartui.R;

/**
 * Builds the more information dialog.
 *
 * @author Tilen Faganel
 * @version 1.0.1
 * @since 1.0.0
 */
public class MoreInformationDialog extends DialogFragment {

    /**
     * Builds the more information alert dialog.
     * <p/>
     * It sets the newly created dialog message, two buttons and a handler for the positive
     * button.
     *
     * @param savedInstanceState The last saved instance state of the Fragment,
     *                           or null if this is a freshly created Fragment.
     * @return Return a new Dialog instance to be displayed by the Fragment.
     */
    @Override
    public Dialog onCreateDialog ( Bundle savedInstanceState ) {

        AlertDialog.Builder builder = new AlertDialog.Builder( getActivity() );
        builder.setMessage( R.string.dialog_text ).setPositiveButton( R.string.dialog_visit,
                new DialogInterface.OnClickListener() {

                    /**
                     * This method will be invoked when the positive button in the dialog
                     * is clicked.
                     * <p/>
                     * Sets up an intent to visit a website with a web browser and starts an
                     * activity with it.
                     *
                     * @param dialog The dialog that received the click.
                     * @param id     The button that was clicked (the position
                     *               of the item clicked.)
                     */
                    public void onClick ( DialogInterface dialog, int id ) {

                        Intent visit = new Intent( Intent.ACTION_VIEW,
                                Uri.parse( "http://www.moma.org" ) );
                        Intent chooser = Intent.createChooser( visit,
                                getResources().getString( R.string.open_with ) );
                        startActivity( chooser );
                            }
                        } ).setNegativeButton( R.string.dialog_not_now, null );

        return builder.create();
    }
}




Java Source Code List

course.lab.modernartui.ApplicationTest.java
course.lab.modernartui.activities.MainActivity.java
course.lab.modernartui.dialogs.MoreInformationDialog.java