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.mEmoZz.qrgen.MainActivity.java

public void mCore() {

    Toast.makeText(getApplicationContext(), "Generating code...", Toast.LENGTH_SHORT).show();

    new CountDownTimer(3000, 1000) {
        public void onTick(long millisUntilFinished) {
        }/*  w w w. j a  va 2 s.c o m*/

        public void onFinish() {
            Button yupBtn, delBtn, shareBtn;

            Toast.makeText(getApplicationContext(), "Success", Toast.LENGTH_SHORT).show();

            final Dialog dialog = new Dialog(MainActivity.this);
            dialog.setContentView(R.layout.dialog);

            dialog.setTitle("Want to save?");

            iv = (ImageView) dialog.findViewById(R.id.iv);
            iv.setImageBitmap(bm);

            shareBtn = (Button) dialog.findViewById(R.id.shareBtn);
            shareBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    shareIt();
                }
            });

            yupBtn = (Button) dialog.findViewById(R.id.btn1);
            yupBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    mStream();

                    dialog.dismiss();
                }
            });

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

                    Toast.makeText(getApplicationContext(), "Deleted!", Toast.LENGTH_SHORT).show();
                }
            });

            dialog.show();
            dialog.setCancelable(false);
            keepDialog(dialog);
        }
    }.start();

}

From source file:tm.android.chronos.activity.Chronos.java

@SuppressWarnings({ "unchecked", "WeakerAccess" })
public void onClick(View view) {

    switch (view.getId()) {
    case R.id.btn_StopwatchAcitvity:
        Intent intent = new Intent(getBaseContext(), ChronometerActivity.class);
        startActivity(intent);// ww w  .java  2 s .  c o  m
        break;
    case R.id.btn_timerActivity:
        Intent intent3 = new Intent(getBaseContext(), TimerActivity.class);
        startActivity(intent3);
        break;
    case R.id.btn_alarmActivity:
        Intent intent1 = new Intent(this, AlarmActivity.class);
        startActivity(intent1);
        break;
    case R.id.btn_metronomeActivity:
        //                Intent intent2 = new Intent(this, MetronomeActivity.class);
        //                startActivity(intent2);
        //                break;
    default:
        Dialog dialog = new Dialog(this);
        TextView textView = new TextView(this);
        textView.setText("Not yet implemented !\nComing soon.");
        //textView.setTextAppearance(android.R.style.TextAppearance_Large);
        dialog.setContentView(textView);
        dialog.setTitle("Message-oup!!!");
        dialog.show();
    }

}

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

private void setRecyclerViewAdapter() {
    sharesList = databaseHandler.getShares();
    final List<Purchase> salesList = databaseHandler.getSales();

    PurchaseShareAdapter purchaseAdapter = new PurchaseShareAdapter(getContext(), salesList);
    purchaseAdapter.setOnItemClickListener(new PurchaseShareAdapter.OnItemClickListener() {
        @Override/*from   w w  w  .  j  ava  2s . c om*/
        public void onItemClick(View itemView, int position) {
            final Purchase purchase = salesList.get(position);

            final Dialog dialog = new Dialog(getActivity());
            dialog.setTitle("Edit Share Sale");
            dialog.setContentView(R.layout.dialog_sell_share_holdings);
            dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.WRAP_CONTENT);
            dialog.show();

            final Spinner spinner = (Spinner) dialog.findViewById(R.id.existing_spinner);
            ArrayList<String> shares = new ArrayList<>();
            int pos = 0;
            for (int i = 0; i < sharesList.size(); i++) {
                shares.add(sharesList.get(i).getName());
                if (sharesList.get(i).getName().equals(purchase.getName()))
                    pos = i;
            }
            ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getActivity(),
                    android.R.layout.simple_spinner_item, shares);
            spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner.setAdapter(spinnerAdapter);
            spinner.setSelection(pos);
            spinner.setVisibility(View.VISIBLE);

            final EditText quantity = (EditText) dialog.findViewById(R.id.no_of_shares);
            final EditText price = (EditText) dialog.findViewById(R.id.selling_price);
            quantity.setText(String.valueOf(purchase.getQuantity()));
            price.setText(String.valueOf(purchase.getPrice()));

            Calendar calendar = Calendar.getInstance();
            calendar.setTime(purchase.getDate());
            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(SalesShareFragment.this);

            Button sellShareBtn = (Button) dialog.findViewById(R.id.sell_share_btn);
            sellShareBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Purchase p = new Purchase();
                    p.setId(purchase.getId());

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

                    try {
                        p.setQuantity(Integer.parseInt(quantity.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Number of Shares", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    try {
                        p.setPrice(Double.parseDouble(price.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Buying Price", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    p.setType("sell");
                    p.setName(spinner.getSelectedItem().toString());
                    databaseHandler.updatePurchase(p);
                    setRecyclerViewAdapter();
                    dialog.dismiss();
                }
            });
        }
    });
    salesRecyclerView.setHasFixedSize(true);
    salesRecyclerView.setAdapter(purchaseAdapter);
    salesRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
}

From source file:com.example.com.benasque2014.mercurio.FamiliaMapaFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.action_details) {
        Dialog d = new Dialog(getActivity());
        d.setTitle("Detalles del trayecto");
        d.setContentView(R.layout.dialog_details);
        TextView text = (TextView) d.findViewById(R.id.text);
        text.setText("");
        text.append("Nombre: " + recorrido.getName() + "\n");
        text.append("Cdigo: " + recorrido.getCodigo() + "\n");
        text.append("Clase: " + recorrido.getClase() + "\n");
        text.append("Hora inicio: " + recorrido.getHoraInicio() + "\n");
        text.append("Hora fin: " + recorrido.getHoraFin() + "\n");
        text.append("Frecuencia: " + recorrido.getFrecuencia() + "\n");
        text.append("Incidencia: " + recorrido.getIncidencia() + "\n");
        d.show();//from  w w w. j a  v a2s.c  o  m
    }
    return super.onOptionsItemSelected(item);
}

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

@Nullable
@Override/*  www  .j a v a  2 s .c  o m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_share_sales, container, false);

    databaseHandler = new DatabaseHandler(getContext());
    salesRecyclerView = (RecyclerView) root.findViewById(R.id.sales_recycler_view);
    setRecyclerViewAdapter();

    FloatingActionButton sellShareFab = (FloatingActionButton) root.findViewById(R.id.sell_share_fab);
    sellShareFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final Dialog dialog = new Dialog(getContext());
            dialog.setTitle("Sell Share Holdings");
            dialog.setContentView(R.layout.dialog_sell_share_holdings);
            dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.WRAP_CONTENT);
            dialog.show();

            final Spinner spinner = (Spinner) dialog.findViewById(R.id.existing_spinner);

            ArrayList<String> shares = new ArrayList<>();
            for (Share share : sharesList) {
                shares.add(share.getName());
            }
            ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(),
                    android.R.layout.simple_spinner_item, shares);
            spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner.setAdapter(spinnerAdapter);

            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();
                }
            });

            Button sellShareBtn = (Button) dialog.findViewById(R.id.sell_share_btn);
            sellShareBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Purchase purchase = new Purchase();
                    purchase.setId(databaseHandler.getNextKey("purchase"));
                    purchase.setName(spinner.getSelectedItem().toString());

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

                    EditText quantity = (EditText) dialog.findViewById(R.id.no_of_shares);
                    try {
                        purchase.setQuantity(Integer.parseInt(quantity.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Number of Shares", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    EditText price = (EditText) dialog.findViewById(R.id.selling_price);
                    try {
                        purchase.setPrice(Double.parseDouble(price.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Selling Price", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    purchase.setType("sell");
                    databaseHandler.addPurchase(spinner.getSelectedItem().toString(), purchase);
                    setRecyclerViewAdapter();
                    dialog.dismiss();
                }
            });
        }
    });

    return root;
}

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

protected void applicenseDialog() {
    final Dialog aLDialog = new Dialog(IntroActivity.this);
    aLDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    aLDialog.setTitle("License Agreement");
    aLDialog.setCancelable(false);/*  ww w  . ja va 2  s .c  o  m*/
    aLDialog.setCanceledOnTouchOutside(false);
    aLDialog.setContentView(R.layout.app_license_dialog);
    WebView lic = (WebView) aLDialog.findViewById(R.id.atomizeLic);
    Button disagree = (Button) aLDialog.findViewById(R.id.alDialogDisagree);
    Button agree = (Button) aLDialog.findViewById(R.id.alDialogAgree);
    lic.getSettings().setUseWideViewPort(true);
    lic.loadUrl("file:///android_asset/atomizeLicense.html");
    disagree.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            aLDialog.dismiss();
            SharedPreferences.Editor e = getPrefs.edit();
            e.putBoolean("agreedToLicense", false);
            e.apply();
            Intent homeIntent = new Intent(Intent.ACTION_MAIN);
            homeIntent.addCategory(Intent.CATEGORY_HOME);
            homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(homeIntent);
            IntroActivity.this.finish();
            MainActivity.getInstance().finish();
        }
    });
    agree.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SharedPreferences.Editor e = getPrefs.edit();
            e.putBoolean("agreedToLicense", true);
            e.apply();
            aLDialog.dismiss();
        }
    });
    aLDialog.show();
}

From source file:com.qubittech.feelknit.app.MainActivity.java

@Override
protected void onNavItemSelected(int id) {
    switch (id) {
    case 101://www.j  av  a 2 s .c  om
        ShowProfileFragment(ApplicationHelper.getAvatar(getApplicationContext()));
        break;
    case 102:
        ShowCurrentFeelingsFragment();
        break;
    case 103:
        StartUserFeelingsFragment();
        break;
    case 104:
        showCommentsFeelingsFragment();
        break;
    case 105:
        ShowRelatedFeelingFragment();
        break;
    case 106:
        final Dialog d = new Dialog(this, R.style.CustomDialogTheme);
        d.setContentView(R.layout.custom_dialog);
        d.show();

        TextView version = (TextView) d.findViewById(R.id.versionTextView);
        TextView saripaar = (TextView) d.findViewById(R.id.saripaar);
        TextView licenseLink = (TextView) d.findViewById(R.id.licenseLink);
        final TextView license = (TextView) d.findViewById(R.id.license);
        saripaar.setText(Html.fromHtml("<u>android-saripaar</u>"));
        licenseLink.setText(Html.fromHtml("(<u>license</u>)"));

        saripaar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Uri uriUrl = Uri.parse("https://github.com/ragunathjawahar/android-saripaar");
                Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl);
                startActivity(launchBrowser);
            }
        });

        license.setText("Copyright 2012 - 2015 Mobs and Geeks\n\n"
                + "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\n" + "\n"
                + "    http://www.apache.org/licenses/LICENSE-2.0\n" + "\n"
                + "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.");
        licenseLink.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                license.setVisibility(license.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
            }
        });
        try {
            version.setText(getApplicationContext().getPackageManager()
                    .getPackageInfo(getApplicationContext().getPackageName(), 0).versionName);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        TextView close_btn = (TextView) d.findViewById(R.id.okButton);
        close_btn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                d.dismiss();
            }
        });
    }
}

From source file:us.cboyd.android.dicom.DcmBrowser.java

/** onMenuItemSelected handles if something from the options menu is selected */
@Override// w ww . j  a v a2s .co m
public boolean onMenuItemSelected(int featureId, MenuItem item) {

    switch (item.getItemId()) {

    case R.id.app_about:
        Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.dialog_about);
        dialog.setTitle(getResources().getString(R.string.app_name));
        dialog.show();
        return true;

    case R.id.show_hidden:
        item.setChecked(!item.isChecked());
        mListFragment.setHidden(item.isChecked());
        return true;

    case R.id.show_info:
        item.setChecked(!item.isChecked());
        mInfoFragment.refreshTagList(item.isChecked());
        return true;

    case R.id.debug_mode:
        item.setChecked(!item.isChecked());
        mInfoFragment.changeMode(item.isChecked());
        return true;

    default:
        return super.onMenuItemSelected(featureId, item);

    }

}

From source file:com.orange.datavenue.DatasourceListFragment.java

/**
 *
 *///from  w w w  . j a v  a2  s  . c  o  m
private void deleteDatasource() {
    final android.app.Dialog dialog = new android.app.Dialog(getActivity());

    dialog.setContentView(R.layout.delete_dialog);
    dialog.setTitle(R.string.delete);

    TextView info = (TextView) dialog.findViewById(R.id.info_label);
    info.setText(
            String.format(getString(R.string.delete_datasource), Model.instance.currentDatasource.getId()));

    Button deleteButton = (Button) dialog.findViewById(R.id.delete_button);
    deleteButton.setOnClickListener(new Button.OnClickListener() {

        @Override
        public void onClick(View view) {
            Log.d(TAG_NAME, "datasource : " + Model.instance.currentDatasource.getId());

            DeleteDatasourceOperation deleteDatasourceOperation = new DeleteDatasourceOperation(
                    Model.instance.oapiKey, Model.instance.key, Model.instance.currentDatasource,
                    new OperationCallback() {
                        @Override
                        public void process(Object object, Exception exception) {
                            if (exception == null) {
                                getDatasources(); // reload
                            } else {
                                Errors.displayError(getActivity(), exception);
                            }
                        }
                    });

            deleteDatasourceOperation.execute("");

            dialog.dismiss();
        }

    });

    Button cancelDeleteButton = (Button) dialog.findViewById(R.id.cancel_button);
    cancelDeleteButton.setOnClickListener(new Button.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            dialog.dismiss();
        }
    });

    dialog.setCancelable(false);
    dialog.show();
}

From source file:com.scoreloop.android.coreui.BaseActivity.java

private Dialog createErrorDialog(final int resId) {
    final Dialog dialog = new Dialog(this);
    dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    final View view = getLayoutInflater().inflate(R.layout.sl_dialog_custom, null);
    dialog.setContentView(view);
    dialog.setCanceledOnTouchOutside(true);
    ((TextView) view.findViewById(R.id.message)).setText(getString(resId));
    return dialog;
}