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:nu.firetech.android.pactrack.frontend.ParcelIdDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);

    dialog.setContentView(R.layout.parcel_id_dialog);
    dialog.setTitle(R.string.menu_add_parcel);

    mErrorDialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.id_error_title)
            .setIconAttribute(android.R.attr.alertDialogIcon).setMessage(R.string.id_error_message)
            .setNeutralButton(R.string.ok, new OnClickListener() {
                @Override// w  ww  .  j  a v a2 s .c  o  m
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();

    mDbAdapter = new ParcelDbAdapter(getActivity()).open();

    mParcelText = (EditText) dialog.findViewById(R.id.parcelid);
    mParcelText.setKeyListener(new NumberKeyListener() {
        private char[] acceptedChars = null;

        @Override
        protected char[] getAcceptedChars() {
            if (acceptedChars == null) {
                acceptedChars = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
                        'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
                        'U', 'V', 'W', 'X', 'Y', 'Z' };
            }

            return acceptedChars;
        }

        @Override
        public int getInputType() {
            return InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS;
        }
    });
    mNameText = (EditText) dialog.findViewById(R.id.parcelname);

    ImageButton scanButton = (ImageButton) dialog.findViewById(R.id.barcode);
    scanButton.setOnClickListener(new ScanButtonListener());
    Button cancelButton = (Button) dialog.findViewById(R.id.cancel);
    cancelButton.setOnClickListener(new ClosingButtonListener());
    Button okButton = (Button) dialog.findViewById(R.id.ok);
    okButton.setOnClickListener(new OkListener());

    if (savedInstanceState != null && savedInstanceState.containsKey(ParcelDbAdapter.KEY_ROWID)) {
        mRowId = savedInstanceState.getLong(ParcelDbAdapter.KEY_ROWID);
    }

    boolean loadParcel = false;

    mParcelInitialText = "";
    if (savedInstanceState != null && savedInstanceState.containsKey(ParcelDbAdapter.KEY_PARCEL)) {
        mParcelInitialText = savedInstanceState.getString(ParcelDbAdapter.KEY_PARCEL);
    } else if (mRowId != null) {
        loadParcel = true;
        mParcelInitialText = getString(R.string.loading);
        mParcelText.setEnabled(false);
    }
    mParcelText.setText(mParcelInitialText);

    mNameInitialText = "";
    if (savedInstanceState != null && savedInstanceState.containsKey(ParcelDbAdapter.KEY_NAME)) {
        mNameInitialText = savedInstanceState.getString(ParcelDbAdapter.KEY_NAME);
    } else if (mRowId != null) {
        loadParcel = true;
        mNameInitialText = getString(R.string.loading);
        mNameText.setEnabled(false);
    }
    mNameText.setText(mNameInitialText);

    mFocusedView = null;
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_FOCUSED_FIELD)) {
        mFocusedView = dialog.findViewById(savedInstanceState.getInt(KEY_FOCUSED_FIELD));

        mInitialSelectionStart = mInitialSelectionEnd = 0;
        if (mFocusedView instanceof EditText && savedInstanceState.containsKey(KEY_SELECTION_START)
                && savedInstanceState.containsKey(KEY_SELECTION_END)) {
            mInitialSelectionStart = savedInstanceState.getInt(KEY_SELECTION_START);
            mInitialSelectionEnd = savedInstanceState.getInt(KEY_SELECTION_END);

            Selection.setSelection(((EditText) mFocusedView).getText(), mInitialSelectionStart,
                    mInitialSelectionEnd);
        }
        mFocusedView.requestFocus();
    }

    if (loadParcel) {
        getLoaderManager().initLoader(INITIAL_LOADER_ID, null, this);
    }

    return dialog;
}

From source file:com.google.ytd.SubmitActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    final Dialog dialog = new Dialog(SubmitActivity.this);
    dialog.setTitle("Terms of Service");
    switch (id) {
    case DIALOG_LEGAL:
        dialog.setContentView(R.layout.legal);

        TextView legalText = (TextView) dialog.findViewById(R.id.legal);

        legalText.setText(Util.readFile(this, R.raw.legal).toString());

        dialog.findViewById(R.id.agree).setOnClickListener(new OnClickListener() {
            @Override//from www  .  j  av  a  2 s.c  om
            public void onClick(View v) {
                dialog.cancel();
                getAuthTokenWithPermission(youTubeName);
            }
        });
        dialog.findViewById(R.id.notagree).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.cancel();
            }
        });

        break;
    }

    return dialog;
}

From source file:com.appolis.receiving.AcReceiveOptionMove.java

/**
 * show alert dialog// w w w .j  av  a 2 s.c  o m
 * @param mContext
 * @param strMessages
 */
public void showPopUp(final Context mContext, final String strMessages) {
    final Dialog dialog = new Dialog(mContext, R.style.Dialog_NoTitle);
    dialog.setContentView(R.layout.dialogwarning);
    // set the custom dialog components - text, image and button      
    TextView text2 = (TextView) dialog.findViewById(R.id.tvScantitle2);
    text2.setText(strMessages);

    LanguagePreferences langPref = new LanguagePreferences(mContext);
    Button dialogButtonOk = (Button) dialog.findViewById(R.id.dialogButtonOK);
    dialogButtonOk.setText(langPref.getPreferencesString(GlobalParams.OK, GlobalParams.OK));

    dialogButtonOk.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            scanFlag = GlobalParams.FLAG_ACTIVE;
        }
    });
    dialog.show();
}

From source file:org.mythdroid.remote.TVRemote.java

@Override
public Dialog onCreateDialog(int id) {

    switch (id) {

    case DIALOG_NUMPAD:
        final Dialog pad = new Dialog(this);
        pad.setContentView(R.layout.numpad);
        pad.findViewById(android.R.id.title).setVisibility(View.GONE);
        View button;//from   www .j  a v a  2 s  .  c  o  m
        int size = nums.size();
        for (int i = 0; i < size; i++) {
            int viewId = nums.keyAt(i);
            button = pad.findViewById(viewId);
            button.setTag(nums.get(viewId));
            button.setOnClickListener(this);
        }
        return pad;

    case DIALOG_GUIDE:
        return new AlertDialog.Builder(ctx).setIcon(drawable.ic_menu_upload_you_tube)
                .setTitle(R.string.dispGuide)
                .setAdapter(new ArrayAdapter<String>(ctx, R.layout.simple_list_item_1, new String[] {}), null)
                .create();

    case DIALOG_QUIT:
        OnClickListener cl = new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                switch (which) {
                case Dialog.BUTTON_POSITIVE:
                    jump = true;
                    break;
                case Dialog.BUTTON_NEUTRAL:
                    jump = false;
                    setResult(REMOTE_RESULT_FINISH);
                    break;
                default:
                    return;

                }
                done();
            }
        };

        return new AlertDialog.Builder(ctx).setTitle(R.string.leaveRemote).setMessage(R.string.haltPlayback)
                .setPositiveButton(R.string.yes, cl).setNeutralButton(R.string.no, cl)
                .setNegativeButton(R.string.cancel, cl).create();

    case FRONTEND_CHOOSER:
        return moveHelper.frontendChooserDialog(feMgr, feLock);

    case DIALOG_MOVE:
        return moveHelper.movePromptDialog(feMgr, feLock);

    }

    return super.onCreateDialog(id);

}

From source file:com.trukr.shipper.fragment.RequestStatus.java

public void cancelAlertDialog(Context mContext, String Title, String Content, final int Status) {
    final Dialog dialog = new Dialog(mContext, R.style.Dialog);
    dialog.setCancelable(false);/*  w w w.  j av a  2  s .  com*/
    dialog.setContentView(R.layout.custom_alertdialog);

    // set the custom dialog components - title and content
    TextView alertHead = (TextView) dialog.findViewById(R.id.custom_alertdialog_tv_alerthead);
    alertHead.setText(Title);
    TextView alertContent = (TextView) dialog.findViewById(R.id.custom_alertdialog_tv_alertcontent);
    alertContent.setText(Content);

    View line = (View) dialog.findViewById(R.id.centerLineDialog);
    Button btnDialogCancel = (Button) dialog.findViewById(R.id.custom_alertdialog_btn_cancel);
    line.setVisibility(View.GONE);
    btnDialogCancel.setVisibility(View.GONE);
    Button btnDialogOk = (Button) dialog.findViewById(R.id.custom_alertdialog_btn_ok);
    btnDialogOk.setBackgroundResource(R.drawable.dialogbtnbackground);

    // if button is clicked, close the custom dialog
    btnDialogOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (Status == 100) {
                dialog.dismiss();
            } else
                dialog.dismiss();
        }
    });
    dialog.show();
}

From source file:com.trukr.shipper.fragment.RequestStatus.java

public void cancelalertdialog(Context mContext, String Title, String Content, final int Status) {
    final Dialog dialog = new Dialog(mContext, R.style.Dialog);
    dialog.setCancelable(false);// w  w  w .  j  a v  a  2 s .c  om
    dialog.setContentView(R.layout.custom_alertdialog);

    // set the custom dialog components - title and content
    TextView alertHead = (TextView) dialog.findViewById(R.id.custom_alertdialog_tv_alerthead);
    alertHead.setText(Title);
    TextView alertContent = (TextView) dialog.findViewById(R.id.custom_alertdialog_tv_alertcontent);
    alertContent.setText(Content);

    View line = (View) dialog.findViewById(R.id.centerLineDialog);
    Button btnDialogCancel = (Button) dialog.findViewById(R.id.custom_alertdialog_btn_cancel);
    /* line.setVisibility(View.GONE);
    btnDialogCancel.setVisibility(View.GONE);*/
    Button btnDialogOk = (Button) dialog.findViewById(R.id.custom_alertdialog_btn_ok);
    /* btnDialogOk.setBackgroundResource(R.drawable.dialogbtnbackground);*/

    // if button is clicked, close the custom dialog
    btnDialogOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
            cancelJob();
        }
    });
    btnDialogCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });
    dialog.show();
}

From source file:com.bitants.wally.fragments.ImageZoomFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (getActivity() != null) {
        final Dialog dialog = new Dialog(getActivity());
        dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.activity_image_zoom);
        dialog.getWindow().setBackgroundDrawableResource(R.color.Transparent);
        WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
        layoutParams.copyFrom(dialog.getWindow().getAttributes());
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
        dialog.getWindow().setAttributes(layoutParams);
        initToolbar(dialog);/*ww  w .  j av  a2 s.  co  m*/
        progressBar = dialog.findViewById(R.id.zoom_loader);
        zoomableImageView = (PhotoView) dialog.findViewById(R.id.image_zoom_photoview);
        if (bitmap != null) {
            if (rect != null) {
                animateIn(dialog);
            }
        } else if (fileUri != null) {
            showLoader();
            Glide.with(getActivity()).load(fileUri).fitCenter()
                    .listener(new RequestListener<Uri, GlideDrawable>() {
                        @Override
                        public boolean onException(Exception e, Uri model, Target<GlideDrawable> target,
                                boolean isFirstResource) {
                            return false;
                        }

                        @Override
                        public boolean onResourceReady(GlideDrawable resource, Uri model,
                                Target<GlideDrawable> target, boolean isFromMemoryCache,
                                boolean isFirstResource) {
                            hideLoader();
                            return false;
                        }
                    }).into(zoomableImageView);
        } else {
            dismiss();
        }
        photoViewAttacher = new PhotoViewAttacher(zoomableImageView);
        photoViewAttacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
            @Override
            public void onViewTap(View view, float x, float y) {
                dismiss();
            }
        });
        return dialog;
    } else {
        return null;
    }
}

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

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog d = super.onCreateDialog(savedInstanceState);
    d.setContentView(R.layout.sample_stats);
    d.setTitle("Anonymous Statistics");
    StringBuilder html = new StringBuilder();
    html.append("<html><p>Your privacy is important to us. You can help us build a better Musubi ")
            .append("by sharing anonymous usage statistics, which includes things like:</p>").append("<p>")
            .append("\t&#149;Number of accounts connected<br/>")
            .append("\t&#149;Number of conversations started<br/>")
            .append("\t&#149;Number of messages sent<br/>").append("\t&#149;Number of sketches drawn<br/>")
            .append("\t&#149;When you update your profile<br/>").append("</p>");
    SharedPreferences p = getActivity().getSharedPreferences(SettingsActivity.PREFS_NAME, 0);
    if (p.getBoolean(SettingsActivity.PREF_ANONYMOUS_STATS, true)) {
        html.append("<p><b>Thank you for helping us improve Musubi!</b></p>");
    }//from   w  w w  .  j av  a  2 s . c om
    html.append("</html>");
    TextView sample_text = (TextView) d.findViewById(R.id.stat_text);
    sample_text.setText(Html.fromHtml(html.toString()));
    Button ok_button = (Button) d.findViewById(R.id.stat_ok);
    ok_button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    return d;
}

From source file:org.ohmage.reminders.types.location.LocTrigMapsActivity.java

private void showHelpDialog() {
    Dialog dialog = new Dialog(this);

    dialog.setContentView(R.layout.trigger_loc_maps_tips);
    dialog.setTitle(R.string.trigger_loc_defining_locations);
    dialog.setOwnerActivity(this);
    dialog.show();/*from  ww  w. ja  va2 s .  c om*/

    WebView webView = (WebView) dialog.findViewById(R.id.web_view);
    webView.loadUrl("file:///android_res/raw/trigger_loc_maps_help.html");

    CheckBox checkBox = (CheckBox) dialog.findViewById(R.id.check_do_not_show);
    checkBox.setChecked(shouldSkipToolTip());
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            SharedPreferences pref = LocTrigMapsActivity.this.getSharedPreferences(TOOL_TIP_PREF_NAME,
                    Context.MODE_PRIVATE);

            SharedPreferences.Editor editor = pref.edit();
            editor.putBoolean(KEY_TOOL_TIP_DO_NT_SHOW, isChecked);
            editor.commit();
        }
    });

    Button button = (Button) dialog.findViewById(R.id.button_close);
    button.setTag(dialog);
    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Object tag = v.getTag();
            if (tag != null && tag instanceof Dialog) {
                ((Dialog) tag).dismiss();
            }
        }
    });
}

From source file:com.neighbor.ex.tong.ui.activity.MainActivity2Activity.java

private void showDialogAree() {
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    dialog.setContentView(R.layout.dialog_agree); // custom_dialog.xml  ? layout  ?? view .
    WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
    params.width = LinearLayout.LayoutParams.MATCH_PARENT;
    final CheckBox accountLicense = (CheckBox) dialog.findViewById(R.id.checkBoxAgree);
    final Button agreeBtn = (Button) dialog.findViewById(R.id.buttonAgree);
    final Button agreeCancelBtn = (Button) dialog.findViewById(R.id.buttonAgreeCancel);
    agreeBtn.setOnClickListener(new View.OnClickListener() {
        @Override/*ww w  . jav a2s.c  o  m*/
        public void onClick(View view) {
            if (accountLicense.isChecked()) {
                SharedPreferenceManager.setValue(MainActivity2Activity.this,
                        SharedPreferenceManager.positionAgree, "true");
                dialog.dismiss();
            }
        }
    });
    agreeCancelBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
}