Example usage for android.app Dialog Dialog

List of usage examples for android.app Dialog Dialog

Introduction

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

Prototype

public Dialog(@NonNull Context context) 

Source Link

Document

Creates a dialog window that uses the default dialog theme.

Usage

From source file:com.osama.cgpacalculator.MainActivity.java

@SuppressLint("InflateParams")
private void showAboutDialog() {
    final ScaleAnimation animation = new ScaleAnimation(0f, 1f, 0f, 1f);
    animation.setDuration(800);//from  w w  w.  java  2  s.c om

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

    final FrameLayout frame = ((FrameLayout) dialog.findViewById(R.id.about_content_layout));
    frame.addView(getLayoutInflater().inflate(R.layout.intro_section_layout, null));

    dialog.findViewById(R.id.credit_dialog_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            frame.removeAllViews();
            isShowingLi = false;
            if (!isShowingCr) {
                frame.addView(getLayoutInflater().inflate(R.layout.credits_layout, null));
                isShowingCr = true;
                frame.setAnimation(animation);
            } else {
                frame.addView(getLayoutInflater().inflate(R.layout.intro_section_layout, null));
                isShowingCr = false;
                frame.setAnimation(animation);
            }
            frame.animate();
        }
    });

    dialog.findViewById(R.id.license_dialog_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            frame.removeAllViews();
            isShowingCr = false;
            if (!isShowingLi) {
                frame.addView(getLayoutInflater().inflate(R.layout.license_layout, null));
                isShowingLi = true;
                frame.setAnimation(animation);
            } else {
                frame.addView(getLayoutInflater().inflate(R.layout.intro_section_layout, null));
                isShowingLi = false;
                frame.setAnimation(animation);
            }
            frame.animate();
        }
    });

    dialog.show();
}

From source file:com.sonymobile.androidapp.gridcomputing.activities.WizardActivity.java

/**
 * Show read more dialog./*from   w  w w  . j a v a 2 s  .  co m*/
 */
public final void showReadMoreDialog() {
    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.dialog_wizard_info);

    // Fullscreen
    dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    dialog.setTitle(R.string.more_info);
    final String[] texts = getResources().getStringArray(R.array.help_find_cure);

    ((TextView) dialog.findViewById(R.id.more_info_tv1)).setText(texts[0]);
    ((TextView) dialog.findViewById(R.id.more_info_tv2)).setText(texts[1]);
    ((TextView) dialog.findViewById(R.id.more_info_tv3)).setText(texts[2]);

    dialog.findViewById(R.id.bt_wizard_done).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View view) {
            dialog.dismiss();
        }
    });
    dialog.show();
}

From source file:com.zpwebsites.linuxonandroid.opensource.Install_Backtrack_2.java

private void downloadImage(Context context, final String torrentName, final String sourceforgeName) {
    if (torrentName.equals("")) {
        Intent localIntent = new Intent("android.intent.action.VIEW");
        localIntent.setData(Uri.parse(sourceforgeName));
        startActivity(localIntent);/*  ww w.  j  av  a  2 s.c om*/
        return;
    }

    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_download_type_selector);
    //          dialog.setTitle(R.string.dialog_select_donwload_type_title);
    dialog.setCancelable(true);

    Button btn_Torrent = (Button) dialog.findViewById(R.id.btn_Torrent);
    btn_Torrent.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent localIntent = new Intent("android.intent.action.VIEW");
            localIntent.setData(Uri.parse(torrentName));
            startActivity(localIntent);
            dialog.dismiss();
        }
    });

    Button btn_Sourceforge = (Button) dialog.findViewById(R.id.btn_Sourceforge);
    btn_Sourceforge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent localIntent = new Intent("android.intent.action.VIEW");
            localIntent.setData(Uri.parse(sourceforgeName));
            startActivity(localIntent);
            dialog.dismiss();
        }
    });

    Button btn_Cancel = (Button) dialog.findViewById(R.id.btn_Cancel);
    btn_Cancel.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    dialog.show();
}

From source file:com.procleus.brime.ui.LabelsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    ((MainActivity) getActivity()).setActionBarTitle("Labels");
    ((MainActivity) getActivity()).showFloatingActionButton(true);
    final View v = inflater.inflate(R.layout.labels_gragment, container, false);
    final NotesDbHelperOld tn = new NotesDbHelperOld(getActivity());

    labelsRetrieved = new ArrayList<String>();
    labelsRetrieved = tn.retrieveLabel();

    listView = (ListView) v.findViewById(R.id.listLabel);
    final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(),
            android.R.layout.simple_list_item_1, labelsRetrieved);
    listView.setAdapter(arrayAdapter);/*ww  w  .  j  a  v a2  s . co m*/
    ImageButton addLabelBtn = (ImageButton) v.findViewById(R.id.addLabelBtn);

    addLabelBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            addLabelFunc(v, tn);
        }
    });

    /*/WORK OF LONG ITEM CLICK LISTENER*/

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(final AdapterView<?> parent, View view, final int position, long id) {

            final Dialog dialog = new Dialog(getContext());
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            dialog.setCancelable(false);
            dialog.setContentView(R.layout.dialog_label);
            dialog.show();

            final Button negative = (Button) dialog.findViewById(R.id.btn_no_label);
            final Button positive = (Button) dialog.findViewById(R.id.btn_yes_label);

            negative.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    dialog.dismiss();

                }
            });

            positive.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    Log.i("brinjal", "Yes");

                    tn.deleteTextNote(String.valueOf(parent.getItemAtPosition(position)));
                    final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(getContext(),
                            android.R.layout.simple_list_item_1, labelsRetrieved);
                    listView.setAdapter(arrayAdapter);
                    dialog.dismiss();

                }

            });

            return true;

        }
    });

    return v;
}

From source file:com.osama.cryptofm.startup.OptionActivity.java

private void generateKeys() {
    //show password dialog
    final Dialog dialog = new Dialog(this);
    dialog.setCancelable(false);/*ww w  . j  av a 2s. co  m*/
    dialog.setContentView(R.layout.passwords_fragment_layout);
    dialog.setTitle("keys password");
    final TextInputEditText editText = (TextInputEditText) dialog.findViewById(R.id.gen_keys_password_edit);
    final TextInputEditText confirmEditText = (TextInputEditText) dialog
            .findViewById(R.id.gen_keys_password_edit_confirm);
    dialog.show();

    dialog.findViewById(R.id.trigger_gen_key_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            //test the passwords
            if (isValidPassword(editText.getText())) {
                if (editText.getText().toString().equals(confirmEditText.getText().toString())) {
                    //be sure to dismiss the dialog
                    dialog.dismiss();
                    //start the async task
                    mKeyPassword = editText.getText().toString();
                    new KeyGenerationTask().execute();
                } else {
                    confirmEditText.setError("Password does not match");
                }
            } else {
                editText.setError("Password should contain at least three characters");
            }

        }
    });
    dialog.findViewById(R.id.cancel_dialog_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });
}

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

@Nullable
@Override/*from   w ww . j a  v  a2  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.zpwebsites.linuxonandroid.Install_Kali_2.java

private void downloadImage(Context context, final String torrentName, final String sourceforgeName) {
    if (torrentName.equals("")) {
        Intent localIntent = new Intent("android.intent.action.VIEW");
        localIntent.setData(Uri.parse(sourceforgeName));
        startActivity(localIntent);/*from ww w .ja  v  a 2 s  . c om*/
        return;
    }

    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_download_type_selector);
    // dialog.setTitle(R.string.dialog_select_donwload_type_title);
    dialog.setCancelable(true);

    Button btn_Torrent = (Button) dialog.findViewById(R.id.btn_Torrent);
    btn_Torrent.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent localIntent = new Intent("android.intent.action.VIEW");
            localIntent.setData(Uri.parse(torrentName));
            startActivity(localIntent);
            dialog.dismiss();
        }
    });

    Button btn_Sourceforge = (Button) dialog.findViewById(R.id.btn_Sourceforge);
    btn_Sourceforge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent localIntent = new Intent("android.intent.action.VIEW");
            localIntent.setData(Uri.parse(sourceforgeName));
            startActivity(localIntent);
            dialog.dismiss();
        }
    });

    Button btn_Cancel = (Button) dialog.findViewById(R.id.btn_Cancel);
    btn_Cancel.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    dialog.show();
}

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

@Nullable
@Override/*from   w  w w.j  av  a2s  .c  o 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.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();// w  ww  .  j  av  a2  s . c  o  m
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.privacity.ListaPerfilActivity.java

@Override
protected void onResume() {
    super.onResume();

    Eventos = new ArrayList<HashMap<String, String>>();
    com = new ConexionSiabra(this);
    JSONObject jsonObject = com.getListaPerfiles();

    String[] perfiles = this.getIntent().getStringArrayExtra("perfiles");
    String[] perfilesCodigo = this.getIntent().getStringArrayExtra("perfilesCodigo");

    if (!jsonObject.has("Error") && !jsonObject.has("detail")) {
        try {/*w w w. j a  v  a  2 s  .co  m*/
            perfiles = new String[jsonObject.length()];
            perfilesCodigo = new String[jsonObject.length()];
            for (int i = 0; i < jsonObject.length(); i++) {
                JSONArray array = jsonObject.getJSONArray(String.valueOf(i));
                perfiles[i] = array.getString(0);
                perfilesCodigo[i] = array.getString(1);
            }
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            Log.wtf("Error", e);
        }

        for (int i = 0; i < perfiles.length; i++) {
            HashMap<String, String> datosEvento = new HashMap<String, String>();
            datosEvento.put("username", perfiles[i]);
            datosEvento.put("codigo", perfilesCodigo[i]);
            Eventos.add(datosEvento);
        }

    } // IF no hay error
    else {
        Dialog dialogo = new Dialog(this);
        dialogo.setTitle(getResources().getString(R.string.errorDeConexion));
        dialogo.show();
    }

    // PINTA TODAS LAS FILAS
    SimpleAdapter ListadoAdapter = new SimpleAdapter(this, Eventos, R.layout.row, from, to);
    setListAdapter(ListadoAdapter);
}