Example usage for android.app Dialog findViewById

List of usage examples for android.app Dialog findViewById

Introduction

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

Prototype

@Nullable
public <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID or null if the ID is invalid (< 0), there is no matching view in the hierarchy, or the dialog has not yet been fully created (for example, via #show() or #create() ).

Usage

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

void openFile(final String filename) {
    if (SharedData.IS_IN_COPY_MODE) {
        return;/*from   w ww . ja  va 2  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:com.bitants.wally.fragments.ImageZoomFragment.java

private void initToolbar(Dialog dialog) {
    toolBar = (ViewGroup) dialog.findViewById(R.id.zoom_toolbar);
    toolBar.setVisibility(toolBarVisibility);
    if (fileUri != null) {
        Button setAsButton = (Button) toolBar.findViewById(R.id.toolbar_set_as);
        setAsButton.setOnClickListener(new View.OnClickListener() {
            @Override/*from www . ja v  a  2 s .  c o  m*/
            public void onClick(View v) {
                setImageAsWallpaperPicker(fileUri);
            }
        });
    }
    if (contentUri != null) {
        Button deleteButton = (Button) toolBar.findViewById(R.id.toolbar_delete);
        deleteButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String quantityString = getResources().getQuantityString(R.plurals.wallpapers, 1);
                String title = String.format(getString(R.string.dialog_delete_title), quantityString);

                FragmentManager fragmentManager = getFragmentManager();

                if (fragmentManager != null) {

                    final MaterialDialogFragment materialDialogFragment = new MaterialDialogFragment();
                    materialDialogFragment
                            .setPrimaryColor(getResources().getColor(R.color.Dialog_Button_Delete));
                    materialDialogFragment.setTitle(title);
                    materialDialogFragment.setPositiveButton(R.string.dialog_delete_positive,
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialogInterface, int i) {
                                    delete(contentUri);
                                }
                            });
                    materialDialogFragment.setNegativeButton(R.string.dialog_delete_negative,
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialogInterface, int i) {
                                    materialDialogFragment.dismiss();
                                }
                            });
                    materialDialogFragment.show(fragmentManager, MaterialDialogFragment.TAG);
                }
            }
        });
    }
}

From source file:no.barentswatch.fiskinfo.MyPageActivity.java

private void createSettingsDialog() {
    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.dialog_settings);
    dialog.setTitle(R.string.settings);/* w w  w .jav a2s  . co  m*/

    Button setStoragePathButton = (Button) dialog.findViewById(R.id.settings_dialog_set_storage_path_button);
    Button logOutButton = (Button) dialog.findViewById(R.id.settings_dialog_log_out_button);
    Button okButton = (Button) dialog.findViewById(R.id.settings_dialog_ok_button);

    setStoragePathButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            createFileDialog();
        }
    });

    logOutButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            createConfirmLogoutDialog(getContext(), R.string.log_out, R.string.confirm_log_out);
        }
    });

    okButton.setOnClickListener(new View.OnClickListener() {

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

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

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

/**
 * Show read more dialog.//w w  w .  j av a 2  s .com
 */
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.untie.daywal.activity.MainActivity.java

private void showDayPicker() {

    Calendar calender = Calendar.getInstance();
    pickedYear = calender.get(Calendar.YEAR);
    pickedMonth = calender.get(Calendar.MONTH) + 1;
    final Dialog dayPickerDialog = new Dialog(this);
    dayPickerDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dayPickerDialog.setContentView(R.layout.dialog);
    Button okBtn = (Button) dayPickerDialog.findViewById(R.id.birthday_btn_ok);
    Button cancelBtn = (Button) dayPickerDialog.findViewById(R.id.birthday_btn_cancel);
    dialog_year_title = (TextView) dayPickerDialog.findViewById(R.id.dialog_year_title);
    dialog_month_title = (TextView) dayPickerDialog.findViewById(R.id.dialog_month_title);
    final NumberPicker yearPicker = (NumberPicker) dayPickerDialog.findViewById(R.id.yearPicker);
    final NumberPicker monthPicker = (NumberPicker) dayPickerDialog.findViewById(R.id.monthPicker);

    dialog_year_title.setText(String.valueOf(pickedYear) + "");
    dialog_month_title.setText(String.valueOf(pickedMonth) + "");
    yearPicker.setMinValue(pickedYear - 100);
    yearPicker.setMaxValue(pickedYear + 40);
    yearPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    //   setDividerColor(yearPicker, android.R.color.white );
    yearPicker.setWrapSelectorWheel(false);
    yearPicker.setValue(pickedYear);//  www  .  jav a  2s  .co m
    yearPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
        @Override
        public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            dialog_year_title.setText(String.valueOf(newVal) + "");
        }
    });

    monthPicker.setMinValue(1);
    monthPicker.setMaxValue(12);
    monthPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    //   setDividerColor(monthPicker, android.R.color.white);
    //monthPicker.setWrapSelectorWheel(false);
    monthPicker.setValue(pickedMonth);
    monthPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
        @Override
        public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            dialog_month_title.setText(String.valueOf(newVal) + "");
        }
    });

    okBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //TODO :  ?? yearPicker.getValue() monthPicker.getValue()

            //Toast.makeText(MainActivity.this, String.valueOf(yearPicker.getValue())+"/"+monthPicker.getValue(), Toast.LENGTH_SHORT).show();

            Intent intent = new Intent(MainActivity.this, MainActivity.class);
            intent.putExtra("year", yearPicker.getValue());
            intent.putExtra("month", monthPicker.getValue());
            intent.putExtra("order", 1);
            dayPickerDialog.dismiss();
            startActivity(intent);
            overridePendingTransition(0, 0);

        }
    });
    cancelBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dayPickerDialog.dismiss();
        }
    });
    dayPickerDialog.show();

}

From source file:com.tutor.activity.SlidingActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {

        if (isShowLeft) {
            this.isShowLeft = mSlidingMenu.showLeftView();
            return false;
        }// www .  java2  s .com
        final Dialog dialog = new Dialog(this, R.style.Theme_dialog);
        dialog.setCanceledOnTouchOutside(true);
        View view = LayoutInflater.from(this).inflate(R.layout.dialog_yesno_layout, null);
        dialog.setContentView(view);
        TextView tvMessage = (TextView) dialog.findViewById(R.id.tvMessage);
        tvMessage.setText("");

        Button confirmButton = (Button) dialog.findViewById(R.id.btnConfirm);
        confirmButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                finish();
                android.os.Process.killProcess(android.os.Process.myPid());
            }
        });

        Button cancelButton = (Button) dialog.findViewById(R.id.btnCancel);
        cancelButton.setOnClickListener(new OnClickListener() {

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

        dialog.show();
    }

    return false;
}

From source file:com.laquysoft.bycon.GoogleCardsActivity.java

public void postOrder(View w) {
    Log.i("ListActivity", "Post Order");
    new OrderTask().execute();

    // custom dialog
    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.payment_dialog);
    dialog.setTitle("Place & Pay Order");

    // set the custom dialog components - text, image and button
    ImageView image = (ImageView) dialog.findViewById(R.id.image);
    image.setImageResource(R.drawable.ic_launcher);

    Button dialogButton = (Button) dialog.findViewById(R.id.btn_accept);
    // if button is clicked, close the custom dialog
    dialogButton.setOnClickListener(new View.OnClickListener() {
        @Override//from w  ww  .  j av a2  s  . c o  m
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    Button dialogCancelButton = (Button) dialog.findViewById(R.id.btn_reject);
    // if button is clicked, close the custom dialog
    dialogCancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    dialog.show();
}

From source file:de.domjos.schooltools.activities.LearningCardOverviewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.learning_card_overview_activity);
    this.initControls();

    this.cmdLearningCardQueryStart.setOnClickListener(new View.OnClickListener() {
        @Override/*  w ww. j  a va2s.  com*/
        public void onClick(View v) {
            final LearningCardQueryTraining learningCardQueryTraining = new LearningCardQueryTraining();
            if (cmdLearningCardQueryStart.getText().equals(getString(R.string.learningCard_query))) {
                final Dialog dialog = new Dialog(LearningCardOverviewActivity.this);
                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                dialog.setContentView(R.layout.learning_card_dialog);
                dialog.setCancelable(true);

                final Spinner spLearningCardQuery = dialog.findViewById(R.id.spLearningCardQueries);
                final ArrayAdapter<LearningCardQuery> learningCardQueries = new ArrayAdapter<>(
                        getApplicationContext(), android.R.layout.simple_spinner_item,
                        MainActivity.globals.getSqLite().getLearningCardQueries(""));
                spLearningCardQuery.setAdapter(learningCardQueries);
                learningCardQueries.notifyDataSetChanged();

                final Button btnStartSop = dialog.findViewById(R.id.cmdStart);
                btnStartSop.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        learningCardQueryTraining.setLearningCardQuery(
                                learningCardQueries.getItem(spLearningCardQuery.getSelectedItemPosition()));
                        learningCardQueryTraining.setID(MainActivity.globals.getSqLite()
                                .insertOrUpdateLearningCardQueryTraining(learningCardQueryTraining));
                        cmdLearningCardQueryStart.setText(getString(R.string.learningCard_query_end));
                        fragmentAdapter.setQuery(learningCardQueryTraining);
                        viewPager.setAdapter(fragmentAdapter);
                        dialog.dismiss();
                    }
                });
                dialog.show();
            } else {
                int wrongCards = 0, rightCards = 0, firstTry = 0, secondTry = 0, thirdTry = 0;
                LearningCardQueryTraining reloadedTraining = MainActivity.globals.getSqLite()
                        .getLearningCardQueryTraining("ID=" + learningCardQueryTraining.getID()).get(0);
                for (LearningCardQueryResult result : reloadedTraining.getResults()) {
                    if (result.isResult1() || result.isResult2() || result.isResult3()) {
                        rightCards++;
                        if (result.isResult1()) {
                            firstTry++;
                        } else if (result.isResult2()) {
                            secondTry++;
                        } else {
                            thirdTry++;
                        }
                    } else {
                        wrongCards++;
                    }
                }
                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                        LearningCardOverviewActivity.this);
                alertDialogBuilder.setTitle(R.string.learningCard_result);
                String content = String.format("%s %s%n%s %s%n%s %s%n%s %s%n%s %s%n",
                        getString(R.string.learningCard_result_right), rightCards,
                        getString(R.string.learningCard_result_wrong), wrongCards,
                        getString(R.string.learningCard_result_firstTry), firstTry,
                        getString(R.string.learningCard_result_secondTry), secondTry,
                        getString(R.string.learningCard_result_thirdTry), thirdTry);
                alertDialogBuilder.setMessage(content);
                alertDialogBuilder.create().show();

                cmdLearningCardQueryStart.setText(getString(R.string.learningCard_query));
                fragmentAdapter.setQuery(null);
                viewPager.setAdapter(fragmentAdapter);
            }
        }
    });
}

From source file:nl.sogeti.android.gpstracker.actions.Statistics.java

@Override
protected void onPrepareDialog(int id, Dialog dialog) {
    switch (id) {
    case DIALOG_GRAPHTYPE:
        Button speedtime = (Button) dialog.findViewById(R.id.graphtype_timespeed);
        Button speeddistance = (Button) dialog.findViewById(R.id.graphtype_distancespeed);
        Button altitudetime = (Button) dialog.findViewById(R.id.graphtype_timealtitude);
        Button altitudedistance = (Button) dialog.findViewById(R.id.graphtype_distancealtitude);
        speedtime.setOnClickListener(mGraphControlListener);
        speeddistance.setOnClickListener(mGraphControlListener);
        altitudetime.setOnClickListener(mGraphControlListener);
        altitudedistance.setOnClickListener(mGraphControlListener);
    default:/*from  w  ww .ja v  a 2  s  .  com*/
        break;
    }
    super.onPrepareDialog(id, dialog);
}

From source file:com.starwood.anglerslong.MainActivity.java

/*****************************************************************************************
 * Dialog to show fishing regulations//  ww  w . jav  a  2 s  .c  om
 *****************************************************************************************/
private void displayDialog() {

    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.fishing_reg_dialog);
    dialog.setTitle("Select a State:");

    dialog.findViewById(R.id.sc_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(scUrl));
            startActivity(browserIntent);
        }
    });

    dialog.findViewById(R.id.ga_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(gaUrl));
            startActivity(browserIntent);
        }
    });

    dialog.findViewById(R.id.fl_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(flUrl));
            startActivity(browserIntent);
        }
    });

    dialog.findViewById(R.id.al_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(alUrl));
            startActivity(browserIntent);
        }
    });

    dialog.findViewById(R.id.ms_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(msUrl));
            startActivity(browserIntent);
        }
    });

    dialog.setCanceledOnTouchOutside(true);
    dialog.show();
}