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.idt.ontomedia.geoconsum.BaseActivity.java

private Dialog setDialogWithCheck(int _id) {
    final Dialog dialog = new Dialog(this);

    dialog.setContentView(R.layout.dialog_with_check);

    TextView textViewInfo = (TextView) dialog.findViewById(R.id.text_layout);
    CheckBox checkBox = (CheckBox) dialog.findViewById(R.id.checkBox1);

    switch (_id) {
    case DIALOG_ABOUT_ID: {
        dialog.setTitle(getResources().getString(R.string.dialog_title_about) + " "
                + getResources().getString(R.string.app_name));
        dialog.setCancelable(true);/*  w  w w.  ja  v  a  2s .  c  o m*/

        checkBox.setVisibility(View.GONE);

        ImageView imageViewBanner = (ImageView) dialog.findViewById(R.id.imageViewBanner);
        imageViewBanner.setImageDrawable(getResources().getDrawable(R.drawable.logo_idt));
        imageViewBanner.setVisibility(View.VISIBLE);

        textViewInfo.setText(R.string.dialog_text_about);
    }
    case DIALOG_WARNING_ID: {
        dialog.setTitle(getResources().getString(R.string.dialog_title_warning));
        dialog.setCancelable(false);

        textViewInfo.setText(R.string.dialog_text_warning);

        checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton _buttonView, boolean _isChecked) {
                SharedPreferences sharedPreferences = PreferenceManager
                        .getDefaultSharedPreferences(getBaseContext());
                SharedPreferences.Editor editor = sharedPreferences.edit();
                editor.putBoolean(DialogPreferenceActivity.PREF_DIALOG_CHECK, _isChecked);
                editor.commit();
            }
        });
    }
    }

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

    });

    return dialog;
}

From source file:com.shalzz.attendance.fragment.CaptchaDialogFragment.java

/**
 * Called when the DialogView is started. Used to setup the onClick listeners.
 *///from   ww w.  ja va2s  .  co m
@Override
public void onStart() {
    super.onStart();

    // Reference the views from the layout
    Dialog dialogView = CaptchaDialogFragment.this.getDialog();
    Button bRefreshCaptcha = (Button) dialogView.findViewById(R.id.bRefresh);
    Captxt = (EditText) dialogView.findViewById(R.id.etCapTxt);
    ivCapImg = (ImageView) dialogView.findViewById(R.id.ivCapImg);
    pbar = (ProgressBar) dialogView.findViewById(R.id.progressBar1);

    AlertDialog alertDialog = (AlertDialog) getDialog();
    final Button positiveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);

    // Get the Captcha Image
    getImg();

    // OnClickListener event for the Reload captcha Button
    bRefreshCaptcha.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.i(LoginActivity.class.toString(), "Refreshing Captcha...");
            getImg();
            Captxt.setText("");
        }
    });

    // logs in when user press done on keyboard.
    Captxt.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                positiveButton.performClick();
                return true;
            }
            return false;
        }
    });
}

From source file:com.itime.team.itime.fragments.QRCodeFragment.java

@NonNull
@Override/*from   w  w  w.j  a  v  a  2s.com*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.fragment_profile_qrcode);
    ImageView imageView = (ImageView) dialog.findViewById(R.id.setting_profile_qrcode_img);

    final Bundle arguments = getArguments();
    if (!arguments.isEmpty()) {
        mUserId = arguments.getString(QRCODE_STRING);
    }

    Bitmap qrCodeBitmap;

    // method1: change a fix dip to pixel
    //final int dim = DensityUtil.dip2px(getContext(), 600);

    // method2: get the display size and scale into 7/8
    // This assumes the view is full screen, which is a good assumption
    WindowManager manager = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();
    Point displaySize = new Point();
    display.getSize(displaySize);
    int width = displaySize.x;
    int height = displaySize.y;
    int smallerDimension = width < height ? width : height;
    final int dim = smallerDimension * 7 / 8;

    try {
        qrCodeBitmap = barcodeEncoder.encodeBitmap(mUserId, BarcodeFormat.QR_CODE, dim, dim);
        imageView.setImageBitmap(qrCodeBitmap);
    } catch (WriterException e) {
        Toast.makeText(getActivity(), "QRCode text can not be empty", Toast.LENGTH_SHORT).show();
    }

    return dialog;
}

From source file:com.feathercoin.wallet.feathercoin.util.BitmapFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bitmap bitmap = (Bitmap) getArguments().getParcelable(KEY_BITMAP);

    final Dialog dialog = new Dialog(activity);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.bitmap_dialog);
    dialog.setCanceledOnTouchOutside(true);

    final ImageView imageView = (ImageView) dialog.findViewById(R.id.bitmap_dialog_image);
    imageView.setImageBitmap(bitmap);//from  w ww .  j  av  a2  s.c  o m
    imageView.setOnClickListener(new View.OnClickListener() {
        public void onClick(final View v) {
            dismiss();
        }
    });

    return dialog;
}

From source file:cc.mintcoin.wallet.util.BitmapFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bitmap bitmap = (Bitmap) getArguments().getParcelable(KEY_BITMAP);

    final Dialog dialog = new Dialog(activity);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.bitmap_dialog);
    dialog.setCanceledOnTouchOutside(true);

    final ImageView imageView = (ImageView) dialog.findViewById(R.id.bitmap_dialog_image);
    imageView.setImageBitmap(bitmap);//from  ww w  .  j ava 2 s  .c  o  m
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            dismiss();
        }
    });

    return dialog;
}

From source file:com.bushstar.kobocoin_android_wallet.util.BitmapFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bitmap bitmap = getArguments().getParcelable(KEY_BITMAP);

    final Dialog dialog = new Dialog(activity);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.bitmap_dialog);
    dialog.setCanceledOnTouchOutside(true);

    final ImageView imageView = (ImageView) dialog.findViewById(R.id.bitmap_dialog_image);
    imageView.setImageBitmap(bitmap);//  w w w  . j  a v  a2s .c o m
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            dismiss();
        }
    });

    return dialog;
}

From source file:de.schildbach.wallet.ui.BitmapFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bundle args = getArguments();
    final BitmapDrawable bitmap = new BitmapDrawable(getResources(), (Bitmap) args.getParcelable(KEY_BITMAP));
    bitmap.setFilterBitmap(false);/*from  w ww . j av a2 s .  c o m*/

    final Dialog dialog = new Dialog(activity);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.bitmap_dialog);
    dialog.setCanceledOnTouchOutside(true);

    final ImageView imageView = (ImageView) dialog.findViewById(R.id.bitmap_dialog_image);
    imageView.setImageDrawable(bitmap);
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            dismissAllowingStateLoss();
        }
    });

    return dialog;
}

From source file:com.shalzz.attendance.activity.LoginActivity.java

@Override
public void onDialogPositiveClick(DialogFragment dialog) {

    Dialog dialogView = dialog.getDialog();
    final EditText Captxt = (EditText) dialogView.findViewById(R.id.etCapTxt);

    if (data.isEmpty())
        getHiddenData();/* w w w. j  av a2 s  . c  o m*/

    // workaround for enrollment number.
    String sapid = etSapid.getText().toString();
    if (sapid.length() == 10 && sapid.charAt(0) == '#')
        sapid = sapid.replaceFirst("#", "R");

    new UserAccount(LoginActivity.this).Login(sapid, etPass.getText().toString(), Captxt.getText().toString(),
            data);
    Miscellaneous.closeKeyboard(this, Captxt);
    dialog.dismiss();
}

From source file:com.akhbulatov.wordkeeper.ui.activity.MainActivity.java

@Override
public void onFinishWordEditorDialog(DialogFragment dialog, int positiveTextId) {
    // Add the word
    if (positiveTextId == R.string.word_editor_action_add) {
        mWordListFragment.addWord(dialog);

        // Updates the category list only from the screen "Categories"
        if (mCategoryListFragment != null && mCategoryListFragment.isVisible()) {
            mCategoryListFragment.updateCategoryList();
        } else {//from   ww w . j av  a2  s.  c om
            // Edit the word
            Dialog dialogView = dialog.getDialog();

            EditText editName = dialogView.findViewById(R.id.edit_word_name);
            EditText editTranslation = dialogView.findViewById(R.id.edit_word_translation);
            Spinner spinnerCategories = dialogView.findViewById(R.id.spinner_categories);

            String name = editName.getText().toString();
            String translation = editTranslation.getText().toString();
            String category = spinnerCategories.getSelectedItem().toString();

            mWordListFragment.editWord(name, translation, category);
        }
    }
}

From source file:com.akhbulatov.wordkeeper.ui.activity.MainActivity.java

private void showWordEditorDialog(@StringRes int titleId, @StringRes int positiveTextId,
        @StringRes int negativeTextId) {
    DialogFragment dialog = WordEditorDialog.newInstance(titleId, positiveTextId, negativeTextId);
    dialog.show(getSupportFragmentManager(), null);
    // NOTE! If the method is not called, the app crashes
    getSupportFragmentManager().executePendingTransactions();

    Dialog dialogView = dialog.getDialog();
    Spinner spinnerCategories = dialogView.findViewById(R.id.spinner_categories);

    ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item,
            mWordListFragment.getCategories());
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerCategories.setAdapter(adapter);

    // Receives and shows data of the selected word to edit in the dialog
    // Data is the name, translation and category
    if (positiveTextId == R.string.word_editor_action_edit) {
        EditText editName = dialogView.findViewById(R.id.edit_word_name);
        EditText editTranslation = dialogView.findViewById(R.id.edit_word_translation);

        editName.setText(mWordListFragment.getName());
        editTranslation.setText(mWordListFragment.getTranslation());
        spinnerCategories.setSelection(adapter.getPosition(mWordListFragment.getCategory()));
    }/*from   w  w w .ja v a  2 s  .  c om*/
}