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.simplealertdialog.test.SupportActivityTest.java

public void testButtons() throws Throwable {
    runTestOnUiThread(new Runnable() {
        @Override/*from  w  w w  .  j av a  2 s .c o m*/
        public void run() {
            activity.findViewById(R.id.btn_buttons).performClick();
            activity.getSupportFragmentManager().executePendingTransactions();
        }
    });
    getInstrumentation().waitForIdleSync();
    Fragment f = getActivity().getSupportFragmentManager().findFragmentByTag("dialog");
    assertNotNull(f);
    Dialog d = ((SimpleAlertDialogSupportFragment) f).getDialog();
    assertNotNull(d);
    View positive = d.findViewById(R.id.button_positive);
    assertNotNull(positive);
    final View negative = d.findViewById(R.id.button_negative);
    assertNotNull(negative);
    runTestOnUiThread(new Runnable() {
        @Override
        public void run() {
            negative.performClick();
        }
    });
    getInstrumentation().waitForIdleSync();
}

From source file:com.app.blockydemo.ui.dialogs.ScriptNameDialog.java

private void handleOnShow(final Dialog dialogEditName) {
    final Button positiveButton = ((AlertDialog) dialogEditName).getButton(AlertDialog.BUTTON_POSITIVE);
    positiveButton.setEnabled(false);//from w  w w .  ja v  a2 s .c  om

    EditText dialogEditText = (EditText) dialogEditName.findViewById(R.id.dialog_editor_script_name_edit_text);

    InputMethodManager inputMethodManager = (InputMethodManager) getActivity()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.showSoftInput(dialogEditText, InputMethodManager.SHOW_IMPLICIT);

    dialogEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable editable) {

            String variableName = editable.toString();
            positiveButton.setEnabled(true);
            for (Script local_script : ProjectManager.getInstance().getCurrentSprite().getScriptList()) {
                if (local_script.getName().equals(variableName)
                        && !local_script.getName().equals(script.getName())) {
                    Toast.makeText(getActivity(), R.string.formula_editor_existing_variable, Toast.LENGTH_SHORT)
                            .show();
                    positiveButton.setEnabled(false);
                }
            }

            if (editable.length() == 0) {
                positiveButton.setEnabled(false);
            }
            if (editable.toString().equals(script.getName())) {
                positiveButton.setEnabled(false);
            }
        }
    });
    dialogEditText.setText(script.getName());

}

From source file:com.simplealertdialog.test.SupportActivityTest.java

public void testMessage() throws Throwable {
    runTestOnUiThread(new Runnable() {
        @Override/*  w  w w  . j  a v  a2 s  .  c o  m*/
        public void run() {
            activity.findViewById(R.id.btn_message).performClick();
            activity.getSupportFragmentManager().executePendingTransactions();
        }
    });
    getInstrumentation().waitForIdleSync();
    Fragment f = getActivity().getSupportFragmentManager().findFragmentByTag("dialog");
    assertNotNull(f);
    Dialog d = ((SimpleAlertDialogSupportFragment) f).getDialog();
    assertNotNull(d);
    final View positive = d.findViewById(R.id.button_positive);
    assertNotNull(positive);
    runTestOnUiThread(new Runnable() {
        @Override
        public void run() {
            positive.performClick();
        }
    });
    getInstrumentation().waitForIdleSync();
}

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

private void downloads(Context context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.download_arch_menu);
    dialog.setCancelable(true);//from   www  .j  a  v a  2  s  . co m

    Button btn_DownloadLarge = (Button) dialog.findViewById(R.id.btn_DownloadLarge);
    btn_DownloadLarge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            downloadImage(v.getContext(), CFG.torrentURL_Arch_Large, CFG.imageURL_Arch_Large);
            dialog.dismiss();
        }
    });

    Button btn_DownloadSmall = (Button) dialog.findViewById(R.id.btn_DownloadSmall);
    btn_DownloadSmall.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            downloadImage(v.getContext(), CFG.torrentURL_Arch_Small, CFG.imageURL_Arch_Small);
            dialog.dismiss();
        }
    });

    Button btn_DownloadCore = (Button) dialog.findViewById(R.id.btn_DownloadCore);
    btn_DownloadCore.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            downloadImage(v.getContext(), CFG.torrentURL_Arch_Core, CFG.imageURL_Arch_Core);
            dialog.dismiss();
        }
    });
    dialog.show();
}

From source file:org.hopestarter.wallet.util.BitmapFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Bundle args = getArguments();
    final Bitmap bitmap = (Bitmap) args.getParcelable(KEY_BITMAP);
    final CharSequence label = args.getCharSequence(KEY_LABEL);
    final CharSequence address = args.getCharSequence(KEY_ADDRESS);

    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 www .  j  a v  a 2s  .co  m*/

    final View labelButtonView = dialog.findViewById(R.id.bitmap_dialog_label_button);
    final TextView labelView = (TextView) dialog.findViewById(R.id.bitmap_dialog_label);
    if (getResources().getBoolean(R.bool.show_bitmap_dialog_label) && label != null) {
        labelView.setText(Html.fromHtml(Formats.maybeRemoveOuterHtmlParagraph(label)));
        labelButtonView.setVisibility(View.VISIBLE);

        if (address != null) {
            labelButtonView.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(final View v) {
                    final Intent intent = new Intent(Intent.ACTION_SEND);
                    intent.setType("text/plain");
                    intent.putExtra(Intent.EXTRA_TEXT, address);
                    startActivity(Intent.createChooser(intent, getString(R.string.bitmap_fragment_share)));
                }
            });
        } else {
            labelButtonView.setEnabled(false);
        }
    } else {
        labelButtonView.setVisibility(View.GONE);
    }

    final View dialogView = dialog.findViewById(R.id.bitmap_dialog_group);
    dialogView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            dismiss();
        }
    });

    return dialog;
}

From source file:com.hivewallet.androidclient.wallet.ui.WalletAddressDialogFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    address = getArguments().getString(KEY_ADDRESS);
    final Bitmap qrCode = (Bitmap) getArguments().getParcelable(KEY_QR_CODE);

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

    final ImageView imageView = (ImageView) dialog.findViewById(R.id.iv_qr_code);
    imageView.setImageBitmap(qrCode);/*from w w w  .  jav  a 2s . c om*/
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            dismiss();
        }
    });

    final TextView textView = (TextView) dialog.findViewById(R.id.tv_bitcoin_address);
    textView.setText(address);

    final ImageButton copyButton = (ImageButton) dialog.findViewById(R.id.ib_copy_wallet_address);
    copyButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            handleCopy();
        }
    });

    final ImageButton shareButton = (ImageButton) dialog.findViewById(R.id.ib_share_wallet_address);
    shareButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            handleShare();
        }
    });

    return dialog;
}

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

private void downloads(Context context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.download_fedora_menu);
    dialog.setCancelable(true);/*from   w ww.j  a  v  a  2  s  .  c om*/

    Button btn_DownloadLarge = (Button) dialog.findViewById(R.id.btn_DownloadLarge);
    btn_DownloadLarge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            downloadImage(v.getContext(), CFG.torrentURL_Fedora_Large, CFG.imageURL_Fedora_Large);
            dialog.dismiss();
        }
    });

    Button btn_DownloadSmall = (Button) dialog.findViewById(R.id.btn_DownloadSmall);
    btn_DownloadSmall.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            downloadImage(v.getContext(), CFG.torrentURL_Fedora_Small, CFG.imageURL_Fedora_Small);
            dialog.dismiss();
        }
    });

    Button btn_DownloadCore = (Button) dialog.findViewById(R.id.btn_DownloadCore);
    btn_DownloadCore.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            downloadImage(v.getContext(), CFG.torrentURL_Fedora_Core, CFG.imageURL_Fedora_Core);
            dialog.dismiss();
        }
    });
    dialog.show();
}

From source file:com.zpwebsites.linuxonandroid.Install_Debian_2.java

private void downloads(Context context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.download_debian_menu);
    dialog.setCancelable(true);/*from   w ww  .  ja  va  2s . co  m*/

    Button btn_DownloadLarge = (Button) dialog.findViewById(R.id.btn_DownloadLarge);
    btn_DownloadLarge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            downloadImage(v.getContext(), CFG.torrentURL_Debian_Large, CFG.imageURL_Debian_Large);
            dialog.dismiss();
        }
    });

    Button btn_DownloadSmall = (Button) dialog.findViewById(R.id.btn_DownloadSmall);
    btn_DownloadSmall.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            downloadImage(v.getContext(), CFG.torrentURL_Debian_Small, CFG.imageURL_Debian_Small);
            dialog.dismiss();
        }
    });

    Button btn_DownloadCore = (Button) dialog.findViewById(R.id.btn_DownloadCore);
    btn_DownloadCore.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            downloadImage(v.getContext(), CFG.torrentURL_Debian_Core, CFG.imageURL_Debian_Core);
            dialog.dismiss();
        }
    });
    dialog.show();
}

From source file:org.cirrus.mobi.pegel.PegelFragmentsActivity.java

private Dialog createAboutDialog() {

    Dialog dialog = new Dialog(this);

    dialog.setContentView(R.layout.about_dialog);
    dialog.setTitle("About Pegel-Online v." + app_ver);

    TextView text = (TextView) dialog.findViewById(R.id.about_d_text);
    text.setText(R.string.about);//from  w w  w  .  j a  v a  2  s.  co m
    ImageView image = (ImageView) dialog.findViewById(R.id.about_d_logo);
    image.setImageResource(R.drawable.icon);

    return dialog;
}

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

private void downloads(Context context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.download_ubuntu12_menu);
    dialog.setCancelable(true);//from w ww  .j  av  a  2s  .  c o m

    Button btn_DownloadLarge = (Button) dialog.findViewById(R.id.btn_DownloadLarge);
    btn_DownloadLarge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            downloadImage(v.getContext(), CFG.torrentURL_Ubuntu12_Large, CFG.imageURL_Ubuntu12_Large);
            dialog.dismiss();
        }
    });

    Button btn_DownloadSmall = (Button) dialog.findViewById(R.id.btn_DownloadSmall);
    btn_DownloadSmall.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            downloadImage(v.getContext(), CFG.torrentURL_Ubuntu12_Small, CFG.imageURL_Ubuntu12_Small);
            dialog.dismiss();
        }
    });

    Button btn_DownloadCore = (Button) dialog.findViewById(R.id.btn_DownloadCore);
    btn_DownloadCore.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            downloadImage(v.getContext(), CFG.torrentURL_Ubuntu12_Core, CFG.imageURL_Ubuntu12_Core);
            dialog.dismiss();
        }
    });
    dialog.show();
}