Example usage for android.app Dialog setContentView

List of usage examples for android.app Dialog setContentView

Introduction

In this page you can find the example usage for android.app Dialog setContentView.

Prototype

public void setContentView(@NonNull View view) 

Source Link

Document

Set the screen content to an explicit view.

Usage

From source file:com.adithya321.sharesanalysis.fragments.FundFlowFragment.java

@Nullable
@Override/*from w ww. j a va2 s . co  m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_fund_flow, container, false);

    Window window = getActivity().getWindow();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        window.setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark));
    ((AppCompatActivity) getActivity()).getSupportActionBar()
            .setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorPrimary)));

    databaseHandler = new DatabaseHandler(getContext());
    fundIn = (TextView) root.findViewById(R.id.fund_in);
    fundOut = (TextView) root.findViewById(R.id.fund_out);
    fundsListView = (ListView) root.findViewById(R.id.funds_list_view);
    setViews();

    FloatingActionButton addFundFab = (FloatingActionButton) root.findViewById(R.id.add_fund_fab);
    addFundFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            final Dialog dialog = new Dialog(getContext());
            dialog.setTitle("Add Fund Flow");
            dialog.setContentView(R.layout.dialog_add_fund);
            dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.WRAP_CONTENT);
            dialog.show();

            Calendar calendar = Calendar.getInstance();
            year_start = calendar.get(Calendar.YEAR);
            month_start = calendar.get(Calendar.MONTH) + 1;
            day_start = calendar.get(Calendar.DAY_OF_MONTH);
            final Button selectDate = (Button) dialog.findViewById(R.id.select_date);
            selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/")
                    .append(year_start));
            selectDate.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Dialog dialog = new DatePickerDialog(getActivity(), onDateSetListener, year_start,
                            month_start - 1, day_start);
                    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                        @Override
                        public void onDismiss(DialogInterface dialog) {
                            selectDate.setText(new StringBuilder().append(day_start).append("/")
                                    .append(month_start).append("/").append(year_start));
                        }
                    });
                    dialog.show();
                }
            });

            final EditText amount = (EditText) dialog.findViewById(R.id.amount);
            Button addFundBtn = (Button) dialog.findViewById(R.id.add_fund_btn);
            addFundBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Fund fund = new Fund();
                    fund.setId(databaseHandler.getNextKey("fund"));

                    String stringStartDate = year_start + " " + month_start + " " + day_start;
                    DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH);
                    try {
                        Date date = format.parse(stringStartDate);
                        fund.setDate(date);
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    try {
                        fund.setAmount(Double.parseDouble(amount.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Amount", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    if (((RadioButton) dialog.findViewById(R.id.radioBtn_fund_in)).isChecked())
                        fund.setType("in");
                    else if (((RadioButton) dialog.findViewById(R.id.radioBtn_fund_out)).isChecked())
                        fund.setType("out");
                    else {
                        Toast.makeText(getActivity(), "Invalid Fund Type", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    databaseHandler.addFund(fund);
                    setViews();
                    dialog.dismiss();
                }
            });
        }
    });

    return root;
}

From source file:com.greatnowhere.radar.MainRadarActivity.java

private void showAboutDialog() {
    final Dialog d = new Dialog(this);
    d.setContentView(R.layout.about);
    d.setTitle(R.string.app_name);//from w w  w  .  j av a2s  .c om
    Button dialogOk = (Button) d.findViewById(R.id.aboutIdButtonOK);
    dialogOk.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            d.dismiss();
        }
    });
    d.show();
}

From source file:de.hero.vertretungsplan.PrefsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);

    mySharedPreferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    ListPreference listPref = (ListPreference) findPreference("prefs_benachrichtigungsintervall");
    listPref.setSummary(//from   w w  w . j a  v  a 2 s .  c o m
            getSummaryInterval(mySharedPreferences.getString("prefs_benachrichtigungsintervall", "1")));
    listPref.setOnPreferenceChangeListener(new ListPreference.OnPreferenceChangeListener() {
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            preference.setSummary(getSummaryInterval(newValue.toString()));

            MainActivity.setNewAlarm(getBaseContext(), true, newValue.toString());
            return true;
        }

    });

    Preference klasse = findPreference("prefs_klasse");
    klasse.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        public boolean onPreferenceClick(Preference preference) {
            showDialog(R.string.dialog_klasse);
            return true;
        }
    });

    CheckBoxPreference ckBxPref = (CheckBoxPreference) findPreference("prefs_benachrichtigungen");
    ckBxPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (preference.getKey().equals("prefs_benachrichtigungen")) {
                MainActivity.setNewAlarm(getBaseContext(), !((CheckBoxPreference) preference).isChecked(),
                        mySharedPreferences);
            }
            return true;
        }
    });

    CheckBoxPreference ckBxPrefAppUpdate = (CheckBoxPreference) findPreference("prefs_check_for_app_updates");
    ckBxPrefAppUpdate.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (preference.getKey().equals("prefs_check_for_app_updates")) {
                Intent i = new Intent(getBaseContext(), CheckForAppUpdate.class);
                i.putExtra("setTimer", !((CheckBoxPreference) preference).isChecked());
                if (!((CheckBoxPreference) preference).isChecked()) {
                    i.putExtra("checkNow", true);
                }
                getBaseContext().startService(i);
            }
            return true;
        }
    });

    Preference ueber = findPreference("ueber");
    ueber.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        public boolean onPreferenceClick(Preference preference) {
            Dialog ueberDialog = new Dialog(PrefsActivity.this);

            ueberDialog.setContentView(R.layout.ueber_dialog_layout);
            ueberDialog.setTitle(getString(R.string.ueber));
            ueberDialog.setCancelable(true);
            ueberDialog.setCanceledOnTouchOutside(true);

            TextView dialogText = (TextView) ueberDialog.findViewById(R.id.text_in_dialog);
            dialogText.setTextColor(Color.BLACK);
            dialogText.setAutoLinkMask(Linkify.ALL);

            dialogText.setText(String.format(getString(R.string.ueberTextFormated),
                    getString(R.string.version_nr), getString(R.string.emailAdresseEntwickler),
                    getString(R.string.webAdresseAppDownload), getString(R.string.GNU_GPLwebadresse)));
            ueberDialog.show();
            return true;
        }
    });

    CheckBoxPreference ckBxPrefDebugging = (CheckBoxPreference) findPreference("prefs_debug");
    ckBxPrefDebugging.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (preference.getKey().equals("prefs_debug")) {
                Log.d("PrefsActivity", "new");
                if (!((CheckBoxPreference) preference).isChecked()) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(preference.getContext());

                    builder.setMessage(getString(R.string.debugText)).setTitle(getString(R.string.debugTitel));

                    AlertDialog dialog = builder.create();
                    dialog.show();
                }
            }
            return true;
        }
    });
}

From source file:com.wrmndfzzy.atomize.intro.IntroActivity.java

protected void permissionsDialog() {
    final Dialog pDialog = new Dialog(IntroActivity.this);
    pDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    pDialog.setTitle("Missing Permissions");
    pDialog.setContentView(R.layout.intro_permissions_dialog);
    pDialogConfirm = (Button) pDialog.findViewById(R.id.ipDialogConfirm);
    pDialogConfirm.setOnClickListener(new View.OnClickListener() {
        @Override// w w w  . j a v a  2  s  . c  om
        public void onClick(View v) {
            pDialog.dismiss();
            IntroActivity.this.finish();
        }
    });
    pDialog.show();
}

From source file:com.kaproduction.malibilgiler.MainActivity.java

private void showHakkindaDialog() {

    final Dialog hakkindaDialog = new Dialog(this);
    hakkindaDialog.setContentView(R.layout.layout_hakkinda);

    TextView openSourceMetin = (TextView) hakkindaDialog.findViewById(R.id.textViewHakkindaOpenSource);
    openSourceMetin.setText(/*  w w  w.  j  a  v  a  2s .  co  m*/
            "Ak Kaynak Ktphaneler :\nJoda Time:\njodatime:joda-time:2.9.5\nJoda-Time is licensed under the business-friendly Apache 2.0 license.");

    TextView hakkindaMetin = (TextView) hakkindaDialog.findViewById(R.id.textViewHakkindaMetin);
    hakkindaMetin.setText("Genel Aklama :\nKullanm olduunuz bu uygulamann ierii "
            + "kullancy bilgilendirmek amacyla dzennmi olup, site ierisinde yer alan hibir bilgi "
            + "ziyaretiler tarafndan tavsiye olarak deerlendirilip hibir karar veya eyleme neden olamaz.  "
            + "Uygulama ierii Gelir daresi Bakanl, Sosyal Gvenlik Kurumu ve Trkiye "
            + "statistik Kurumu gibi eitli kurum ve kurululardan edinilen "
            + "verilerden yararlanlarak hazrlanmtr. "
            + "Uygulamann ierii ile ilgili olarak sz konusu kurumlar ile farkllklar "
            + "bulunmas halinde sz konusu kurumlarn verilerinin esas alnmas gerekmektedir."
            + "Uygulamann ieriinden kaynaklanan hatalardan dolay uygulama sorumlu tutulamaz, "
            + "hibir hukuki veya cezai sorumluluk kabul edilmez.  ");

    Button buttonTamam = (Button) hakkindaDialog.findViewById(R.id.buttonHakkindaOK);
    buttonTamam.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            hakkindaDialog.dismiss();
        }
    });

    hakkindaDialog.show();

}

From source file:com.medisa.myspacecal.Range.java

@Override
public void onSideNavigationItemClick(int itemId) {
    switch (itemId) {
    case R.id.side_navigation_menu_calendario:
        range = 0;/*from ww  w  .j a  v  a 2 s.  c o m*/
        Intent i = new Intent(this, MainActivity.class);
        startActivity(i);
        break;
    case R.id.side_navigation_menu_date_range:
        // custom dialog
        final Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.custom_range_date);
        dialog.setTitle("Data range");

        // set the custom dialog components - text, image and button
        final DatePicker dpStart = (DatePicker) dialog.findViewById(R.id.dpStart);
        final DatePicker dpEnd = (DatePicker) dialog.findViewById(R.id.dpEnd);
        Button btnSalva = (Button) dialog.findViewById(R.id.btnSalva);
        final CheckBox cbIntegralBox = (CheckBox) dialog.findViewById(R.id.cbIntegral);
        // if button is clicked, close the custom dialog
        btnSalva.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dateStart = Funzioni.addZero(dpStart.getDayOfMonth(), 2) + "-"
                        + Funzioni.addZero(dpStart.getMonth(), 2) + "-" + dpStart.getYear();
                dateEnd = Funzioni.addZero(dpEnd.getDayOfMonth(), 2) + "-"
                        + Funzioni.addZero(dpEnd.getMonth(), 2) + "-" + dpEnd.getYear();
                Log.e(dateStart, dateEnd);
                if (cbIntegralBox.isChecked()) {
                    //#########################JSON
                    AsyncHttpClient client = new AsyncHttpClient();
                    client.get("http://199.180.196.10/json/integral?startdate=" + dateStart + "&enddate="
                            + dateEnd, new AsyncHttpResponseHandler() {
                                @Override
                                public void onSuccess(String response) {
                                    Log.e("SCARICATO", response);
                                    JSONArray jObject;
                                    try {
                                        jObject = new JSONArray(response);
                                        for (int i = 0; i < jObject.length(); i++) {
                                            JSONArray menuObject = jObject.getJSONArray(i);
                                            String dataStart = menuObject.getString(0);
                                            String dataEnd = menuObject.getString(1);
                                            String raj2000 = menuObject.getString(2);
                                            String decj2000 = menuObject.getString(3);
                                            String target = menuObject.getString(4);
                                            Log.e("", dataStart + " " + dataEnd + " " + raj2000 + " " + decj2000
                                                    + " " + target);
                                            satellitiIntegral.add(new SatelliteIntegral(dataStart, dataEnd,
                                                    raj2000, decj2000, target));
                                        }
                                    } catch (JSONException e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
                                    }
                                }
                            });
                }

                dialog.dismiss();
                //                   Intent mioIntent= new Intent(ctx, Range.class);
                //                   startActivity(mioIntent);
            }

        });
        dialog.show();
        break;
    //            case R.id.side_navigation_menu_item3:
    //                invokeActivity(getString(R.string.title3), R.drawable.ic_android3);
    //                break;
    //
    //            case R.id.side_navigation_menu_item4:
    //                invokeActivity(getString(R.string.title4), R.drawable.ic_android4);
    //                break;
    //
    //            case R.id.side_navigation_menu_item5:
    //                invokeActivity(getString(R.string.title5), R.drawable.ic_android5);
    //                break;

    default:
        return;
    }
}

From source file:com.osama.cryptofm.filemanager.listview.FileSelectionManagement.java

void openFile(final String filename) {
    if (SharedData.IS_IN_COPY_MODE) {
        return;/* w  w  w.  ja va2 s.  com*/
    }
    if (FileUtils.getExtension(filename).equals("pgp")) {
        Log.d(TAG, "openFile: File name is: " + filename);
        if (SharedData.KEY_PASSWORD == null) {
            final Dialog dialog = new Dialog(mContext);
            dialog.setCancelable(false);
            dialog.setContentView(R.layout.password_dialog_layout);
            dialog.show();
            dialog.findViewById(R.id.cancel_decrypt_button).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    dialog.dismiss();
                }
            });
            final EditText editText = (EditText) dialog.findViewById(R.id.key_password);
            dialog.findViewById(R.id.decrypt_file_button).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (editText.getText().length() < 1) {
                        editText.setError("please give me your encryption password");
                        return;
                    } else {
                        SharedData.KEY_PASSWORD = editText.getText().toString();
                        dialog.dismiss();
                        new DecryptTask(mContext, mFileListAdapter, SharedData.DB_PASSWWORD,
                                SharedData.USERNAME, FileUtils.CURRENT_PATH + filename, SharedData.KEY_PASSWORD)
                                        .execute();
                    }

                }
            });
        } else {
            new DecryptTask(mContext, mFileListAdapter, SharedData.DB_PASSWWORD, SharedData.USERNAME,
                    FileUtils.CURRENT_PATH + filename, SharedData.KEY_PASSWORD).execute();
        }

    } else {
        //open file
        if (SharedData.EXTERNAL_SDCARD_ROOT_PATH != null
                && FileUtils.CURRENT_PATH.contains(SharedData.EXTERNAL_SDCARD_ROOT_PATH)) {
            //open the document file
            DocumentFile file = FileDocumentUtils.getDocumentFile(FileUtils.getFile(filename));
            Intent intent = new Intent();
            intent.setDataAndType(file.getUri(), file.getType());
            intent.setAction(Intent.ACTION_VIEW);
            Intent x = Intent.createChooser(intent, "Open with");
            mContext.startActivity(x);
            return;
        }
        String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(FileUtils.getExtension(filename));

        Intent intent = new Intent();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

            Uri uri = FileProvider.getUriForFile(mContext,
                    mContext.getApplicationContext().getPackageName() + ".provider",
                    FileUtils.getFile(filename));
            intent.setDataAndType(uri, mimeType);
        } else {
            intent.setDataAndType(Uri.fromFile(FileUtils.getFile(filename)), mimeType);
        }
        intent.setAction(Intent.ACTION_VIEW);
        Intent x = Intent.createChooser(intent, "Open with: ");
        mContext.startActivity(x);
    }
}

From source file:mobisocial.musubi.ui.fragments.EulaFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setContentView(R.layout.eula);

    //load the tabs
    mTabs = (TabHost) dialog.findViewById(android.R.id.tabhost);
    mTabs.setup();/* w w w  .j a v a2s.  co m*/

    TabSpec tab_one = mTabs.newTabSpec("eula_tab");
    tab_one.setContent(R.id.eula_body);
    tab_one.setIndicator("EULA");
    mTabs.addTab(tab_one);

    TabSpec tab_two = mTabs.newTabSpec("privacy_tab");
    tab_two.setContent(R.id.priv_body);
    tab_two.setIndicator("Privacy Policy");
    mTabs.addTab(tab_two);

    //work around lack of ability to control tab height from xml completely
    TabWidget tab_widget = (TabWidget) dialog.findViewById(android.R.id.tabs);
    mTabs.getTabWidget().getChildAt(0).getLayoutParams().height = tab_widget.getLayoutParams().height;
    mTabs.getTabWidget().getChildAt(1).getLayoutParams().height = tab_widget.getLayoutParams().height;

    //load the agreements
    mEulaScroll = (ScrollView) dialog.findViewById(R.id.eula_scroll);
    mLoading = (LinearLayout) dialog.findViewById(R.id.loading);
    mEulaBodyView = (TextView) dialog.findViewById(R.id.eula_body);
    mPrivacyBodyView = (TextView) dialog.findViewById(R.id.priv_body);

    mAcceptedCheckbox = (CheckBox) dialog.findViewById(R.id.eula_checkbox);
    mAcceptButton = (Button) dialog.findViewById(R.id.eula_accept);
    mRejectButton = (Button) dialog.findViewById(R.id.eula_reject);
    mEmailButton = (Button) dialog.findViewById(R.id.eula_email);
    mDismissButton = (Button) dialog.findViewById(R.id.eula_dismiss);
    mEulaAcceptArea = (LinearLayout) dialog.findViewById(R.id.eula_accept_area);

    mAcceptedCheckbox.setOnCheckedChangeListener(new OnAcceptToggle());
    mAcceptButton.setOnClickListener(new OnAccept());
    mRejectButton.setOnClickListener(new OnReject());
    mEmailButton.setOnClickListener(new OnEmail());
    mDismissButton.setOnClickListener(new OnDismiss());

    if (!mRequired) {
        mEulaAcceptArea.setVisibility(View.GONE);
        mAcceptButton.setVisibility(View.GONE);
        mRejectButton.setVisibility(View.GONE);
        mDismissButton.setVisibility(View.VISIBLE);
    } else {
        mEulaAcceptArea.setVisibility(View.VISIBLE);
        mAcceptButton.setVisibility(View.VISIBLE);
        mRejectButton.setVisibility(View.VISIBLE);
        mDismissButton.setVisibility(View.GONE);
    }

    mAcceptButton.setEnabled(mAcceptedCheckbox.isChecked());
    dialog.setTitle("Musubi Usage Agreements");
    dialog.setOnKeyListener(new OnKey());

    new AgreementLoader().execute();
    return dialog;
}

From source file:com.tgaubert.blefinder.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_reset) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.activity_main_reset_title);
        builder.setMessage(R.string.activity_main_reset_text);
        builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
            @Override//from  w  w  w .  ja va 2s .  c o  m
            public void onClick(DialogInterface dialog, int which) {
                BeaconIO.getSeenBeacons().clear();
                Snackbar.make(findViewById(R.id.floating_btn), R.string.activity_main_reset_done,
                        Snackbar.LENGTH_LONG).show();
            }
        });
        builder.setNegativeButton(R.string.no, null);
        builder.show();
    }

    if (id == R.id.action_about) {
        final Dialog dialog = new Dialog(this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.dialog_about);
        WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        dialog.getWindow().setAttributes(params);
        dialog.show();

        PackageInfo pInfo = null;
        try {
            pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }

        if (pInfo != null)
            ((TextView) dialog.findViewById(R.id.appVersion)).setText(pInfo.versionName);

        dialog.findViewById(R.id.dialogLicenses).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();

                final Dialog licenseDialog = new Dialog(v.getContext());
                licenseDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                licenseDialog.setContentView(R.layout.dialog_licenses);
                WindowManager.LayoutParams licenseParams = licenseDialog.getWindow().getAttributes();
                licenseParams.width = WindowManager.LayoutParams.MATCH_PARENT;
                licenseDialog.getWindow().setAttributes(licenseParams);
                licenseDialog.show();

                String licenses = "<h3>android-beacon-library</h3>" + "<p>Copyright 2014 Radius Networks</p>\n"
                        + "\n" + "   <p>Licensed under the Apache License, Version 2.0 (the \"License\");\n"
                        + "   you may not use this file except in compliance with the License.\n"
                        + "   You may obtain a copy of the License at</p>\n" + "\n"
                        + "       <p>http://www.apache.org/licenses/LICENSE-2.0</p>\n" + "\n"
                        + "   <p>Unless required by applicable law or agreed to in writing, software\n"
                        + "   distributed under the License is distributed on an \"AS IS\" BASIS,\n"
                        + "   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
                        + "   See the License for the specific language governing permissions and\n"
                        + "   limitations under the License.</p>" + "<h3>BottomSheet</h3>"
                        + "<p>Copyright 2011, 2015 Kai Liao</p>\n" + "\n"
                        + "<p>Licensed under the Apache License, Version 2.0 (the \"License\");\n"
                        + "you may not use this file except in compliance with the License.\n"
                        + "You may obtain a copy of the License at</p>\n" + "\n"
                        + "   <p>http://www.apache.org/licenses/LICENSE-2.0</p>\n" + "\n"
                        + "<p>Unless required by applicable law or agreed to in writing, software\n"
                        + "distributed under the License is distributed on an \"AS IS\" BASIS,\n"
                        + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
                        + "See the License for the specific language governing permissions and\n"
                        + "limitations under the License.</p>";

                ((TextView) licenseDialog.findViewById(R.id.dialogText)).setText(Html.fromHtml(licenses));

                licenseDialog.findViewById(R.id.licenseOk).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        licenseDialog.dismiss();
                    }
                });
            }
        });

        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:pulseanddecibels.jp.yamatenki.activity.SplashActivity.java

private void displayUserLicenseAgreement() {
    final Dialog dialog = new Dialog(SplashActivity.this);
    //        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_license_agreement);
    dialog.setTitle(getString(R.string.text_license_agreement_title));
    dialog.setCanceledOnTouchOutside(false);
    Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.yama_brown));
    dialog.getWindow().setBackgroundDrawable(d);
    dialog.show();/*from   w w w  . j ava2  s. co  m*/
    licenseAgreementDialogOpen = true;
    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            if (!agreeButtonPressed) {
                licenseAgreementDialogOpen = false;
                settings.setAgreedToLicense(false);
                if (!databaseTaskRunning) {
                    finish();
                }
            }
        }
    });
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            licenseAgreementDialogOpen = false;
            settings.setAgreedToLicense(false);
            if (!databaseTaskRunning) {
                finish();
            }
        }
    });

    final Button agreeButton = (Button) dialog.findViewById(R.id.agree_button);
    agreeButton.setEnabled(false);
    agreeButton.setAlpha(.5f);
    agreeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            settings.setAgreedToLicense(true);
            agreeButtonPressed = true;
            dialog.dismiss();
            if (!databaseTaskRunning) {
                startMainActivity();
            }
        }
    });

    final CheckBox agreementCheckbox = (CheckBox) dialog.findViewById(R.id.agreement_checkbox);
    agreementCheckbox.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            CheckBox checkbox = (CheckBox) v;
            if (checkbox.isChecked()) {
                agreeButton.setAlpha(1.0f);
                agreeButton.setEnabled(true);
            } else {
                agreeButton.setAlpha(.5f);
                agreeButton.setEnabled(false);
            }
        }
    });

    TextView agreementLabel = (TextView) dialog.findViewById(R.id.agreement_label);
    agreementLabel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            agreementCheckbox.setChecked(!agreementCheckbox.isChecked());
            if (agreementCheckbox.isChecked()) {
                agreeButton.setAlpha(1.0f);
                agreeButton.setEnabled(true);
            } else {
                agreeButton.setAlpha(.5f);
                agreeButton.setEnabled(false);
            }
        }
    });
}