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.FragmentSupportActivityTest.java

public void testAdapter() throws Throwable {
    runTestOnUiThread(new Runnable() {
        @Override/*from   w ww  .  j  a v a 2s  .com*/
        public void run() {
            Fragment f = activity.getSupportFragmentManager().findFragmentById(R.id.fragment_sample);
            assertNotNull(f);
            assertNotNull(f.getView());
            f.getView().findViewById(R.id.btn_frag_adapter).performClick();
            activity.getFragmentManager().executePendingTransactions();
        }
    });
    getInstrumentation().waitForIdleSync();
    Fragment f = getActivity().getSupportFragmentManager().findFragmentByTag("dialog");
    assertNotNull(f);
    Dialog d = ((SimpleAlertDialogSupportFragment) f).getDialog();
    assertNotNull(d);

    final ListView lv = (ListView) d.findViewById(R.id.list);
    assertNotNull(lv);
    assertTrue(lv.getAdapter() instanceof SweetsAdapter);
    runTestOnUiThread(new Runnable() {
        @Override
        public void run() {
            lv.performItemClick(lv, 0, 0);
        }
    });
}

From source file:com.zpwebsites.linuxonandroid.Install_Debian_Testing_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  w w.ja  va 2 s  . co  m

    Button btn_DownloadLarge = (Button) dialog.findViewById(R.id.btn_DownloadLarge);
    btn_DownloadLarge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Large_ext4,
                        CFG.imageURL_Debian_Testing_Large_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Large_ext2,
                        CFG.imageURL_Debian_Testing_Large_ext2);
            }
            dialog.dismiss();
        }
    });

    Button btn_DownloadSmall = (Button) dialog.findViewById(R.id.btn_DownloadSmall);
    btn_DownloadSmall.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Small_ext4,
                        CFG.imageURL_Debian_Testing_Small_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Small_ext2,
                        CFG.imageURL_Debian_Testing_Small_ext2);
            }
            dialog.dismiss();
        }
    });

    Button btn_DownloadCore = (Button) dialog.findViewById(R.id.btn_DownloadCore);
    btn_DownloadCore.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Core_ext4,
                        CFG.imageURL_Debian_Testing_Core_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Core_ext2,
                        CFG.imageURL_Debian_Testing_Core_ext2);
            }
            dialog.dismiss();
        }
    });
    dialog.show();
}

From source file:com.akhbulatov.wordkeeper.ui.fragment.CategoryListFragment.java

private void addCategory(DialogFragment dialog) {
    Dialog dialogView = dialog.getDialog();

    EditText editName = dialogView.findViewById(R.id.edit_category_name);
    String name = editName.getText().toString();

    if (TextUtils.isEmpty(name)) {
        CommonUtils.showToast(getActivity(), R.string.error_category_editor_empty_field);
    } else {//from w w  w .java2  s.  c  o  m
        mCategoryDbAdapter.insert(new Category(name));
        mCategoryList.scrollToPosition(0);
        getLoaderManager().restartLoader(LOADER_ID, null, this);
    }
}

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

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

    Button btn_DownloadLarge = (Button) dialog.findViewById(R.id.btn_DownloadLarge);
    btn_DownloadLarge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu1310_Large_ext4,
                        CFG.imageURL_Ubuntu1310_Large_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu1310_Large_ext2,
                        CFG.imageURL_Ubuntu1310_Large_ext2);
            }
            dialog.dismiss();
        }
    });

    Button btn_DownloadSmall = (Button) dialog.findViewById(R.id.btn_DownloadSmall);
    btn_DownloadSmall.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu1310_Small_ext4,
                        CFG.imageURL_Ubuntu1310_Small_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu1310_Small_ext2,
                        CFG.imageURL_Ubuntu1310_Small_ext2);
            }
            dialog.dismiss();
        }
    });

    Button btn_DownloadCore = (Button) dialog.findViewById(R.id.btn_DownloadCore);
    btn_DownloadCore.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu1310_Core_ext4,
                        CFG.imageURL_Ubuntu1310_Core_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu1310_Core_ext2,
                        CFG.imageURL_Ubuntu1310_Core_ext2);
            }
            dialog.dismiss();
        }
    });
    dialog.show();
}

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

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

    Button btn_DownloadCore = (Button) dialog.findViewById(R.id.btn_DownloadCore);
    btn_DownloadCore.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Core_ext4,
                        CFG.imageURL_Ubuntu13_Core_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Core_ext2,
                        CFG.imageURL_Ubuntu13_Core_ext2);
            }
            dialog.dismiss();
        }
    });

    Button btn_DownloadLarge = (Button) dialog.findViewById(R.id.btn_DownloadLarge);
    btn_DownloadLarge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Large_ext4,
                        CFG.imageURL_Ubuntu13_Large_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Large_ext2,
                        CFG.imageURL_Ubuntu13_Large_ext2);
            }
            dialog.dismiss();
        }
    });

    Button btn_DownloadSmall = (Button) dialog.findViewById(R.id.btn_DownloadSmall);
    btn_DownloadSmall.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Small_ext4,
                        CFG.imageURL_Ubuntu13_Small_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Small_ext2,
                        CFG.imageURL_Ubuntu13_Small_ext2);
            }
            dialog.dismiss();
        }
    });
    dialog.show();

}

From source file:com.akhbulatov.wordkeeper.ui.fragment.CategoryListFragment.java

@Override
public void onFinishCategoryEditorDialog(DialogFragment dialog, int positiveTextId) {
    // Add the category
    if (positiveTextId == R.string.category_editor_action_add) {
        addCategory(dialog);//from   w  ww.j ava  2  s .co m
    } else {
        // Edit the category
        Dialog dialogView = dialog.getDialog();
        EditText editName = dialogView.findViewById(R.id.edit_category_name);
        String name = editName.getText().toString();

        renameCategory(name);
    }
}

From source file:com.akhbulatov.wordkeeper.ui.fragment.CategoryListFragment.java

private void showCategoryEditorDialog(int titleId, int positiveTextId, int negativeTextId) {
    DialogFragment dialog = CategoryEditorDialog.newInstance(titleId, positiveTextId, negativeTextId);
    dialog.setTargetFragment(CategoryListFragment.this, CATEGORY_EDITOR_DIALOG_REQUEST);
    dialog.show(getActivity().getSupportFragmentManager(), null);

    // Receives and shows data of the selected category to edit in the dialog
    // Data is the name of the category
    if (positiveTextId == R.string.category_editor_action_rename) {
        // NOTE! If the method is not called, the app crashes
        getActivity().getSupportFragmentManager().executePendingTransactions();

        Dialog dialogView = dialog.getDialog();
        EditText editName = dialogView.findViewById(R.id.edit_category_name);
        editName.setText(getName());//from   ww w .j av a2s  .c om
    }
}

From source file:de.androvdr.activities.ChannelsActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_WHATS_ON:
        final Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.extendedchannels_whats_on);
        dialog.setTitle(R.string.channels_whats_on);

        final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
        final DatePicker dp = (DatePicker) dialog.findViewById(R.id.channels_datePicker);
        final TimePicker tp = (TimePicker) dialog.findViewById(R.id.channels_timePicker);
        tp.setIs24HourView(DateFormat.is24HourFormat(getApplicationContext()));
        if (sp.contains("whats_on_hour")) {
            tp.setCurrentHour(sp.getInt("whats_on_hour", 0));
            tp.setCurrentMinute(sp.getInt("whats_on_minute", 0));
        }/* www.java  2s .c  o  m*/

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

        button = (Button) dialog.findViewById(R.id.channels_search);
        button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Editor editor = sp.edit();
                editor.putInt("whats_on_hour", tp.getCurrentHour());
                editor.putInt("whats_on_minute", tp.getCurrentMinute());
                editor.commit();

                SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy hh:mm");
                try {
                    long time = df.parse(dp.getDayOfMonth() + "." + (dp.getMonth() + 1) + "." + dp.getYear()
                            + " " + tp.getCurrentHour() + ":" + tp.getCurrentMinute()).getTime() / 1000;
                    getController().whatsOn(time);
                } catch (ParseException e) {
                    logger.error("Couldn't get date from pickers", e);
                }
                dialog.dismiss();
            }
        });
        return dialog;
    default:
        return super.onCreateDialog(id);
    }
}

From source file:com.memetro.android.MainActivity.java

public void showRecoverPassDialog(final Context context) {

    final Dialog mDialog = new Dialog(context);
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mDialog.setContentView(R.layout.dialog_recover);
    mDialog.setCancelable(true);// w  w  w  .j  av a 2  s .com

    final EditText emailText = (EditText) mDialog.findViewById(R.id.email);
    Button sendButton = (Button) mDialog.findViewById(R.id.send);

    sendButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            RecoverPassUtils.recoverPass(context, emailText.getText().toString(), new OAuthHandler() {
                public void onStart() {
                    pdialog.show();
                }

                public void onSuccess() {
                    mDialog.dismiss();
                    MemetroDialog.showDialog(MainActivity.this, null, getString(R.string.recover_ok));
                }

                public void onFailure() {
                    MemetroDialog.showDialog(MainActivity.this, null, getString(R.string.recover_ko));
                }

                public void onFinish() {
                    pdialog.dismiss();
                }
            });
        }
    });

    mDialog.show();
}

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

private void generateKeys() {
    //show password dialog
    final Dialog dialog = new Dialog(this);
    dialog.setCancelable(false);//from  w  ww  .j  ava2s . c om
    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();
        }
    });
}