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.zpwebsites.linuxonandroid.Install_Kali_2.java

private void downloadImage(Context context, final String torrentName, final String sourceforgeName) {
    if (torrentName.equals("")) {
        Intent localIntent = new Intent("android.intent.action.VIEW");
        localIntent.setData(Uri.parse(sourceforgeName));
        startActivity(localIntent);/*from   w  ww  .j  a  va  2  s.c o  m*/
        return;
    }

    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_download_type_selector);
    // dialog.setTitle(R.string.dialog_select_donwload_type_title);
    dialog.setCancelable(true);

    Button btn_Torrent = (Button) dialog.findViewById(R.id.btn_Torrent);
    btn_Torrent.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent localIntent = new Intent("android.intent.action.VIEW");
            localIntent.setData(Uri.parse(torrentName));
            startActivity(localIntent);
            dialog.dismiss();
        }
    });

    Button btn_Sourceforge = (Button) dialog.findViewById(R.id.btn_Sourceforge);
    btn_Sourceforge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent localIntent = new Intent("android.intent.action.VIEW");
            localIntent.setData(Uri.parse(sourceforgeName));
            startActivity(localIntent);
            dialog.dismiss();
        }
    });

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

    dialog.show();
}

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

private void downloadImage(Context context, final String torrentName, final String sourceforgeName) {
    if (torrentName.equals("")) {
        Intent localIntent = new Intent("android.intent.action.VIEW");
        localIntent.setData(Uri.parse(sourceforgeName));
        startActivity(localIntent);/*from  ww w .j  av  a2s  . com*/
        return;
    }

    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_download_type_selector);
    //          dialog.setTitle(R.string.dialog_select_donwload_type_title);
    dialog.setCancelable(true);

    Button btn_Torrent = (Button) dialog.findViewById(R.id.btn_Torrent);
    btn_Torrent.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent localIntent = new Intent("android.intent.action.VIEW");
            localIntent.setData(Uri.parse(torrentName));
            startActivity(localIntent);
            dialog.dismiss();
        }
    });

    Button btn_Sourceforge = (Button) dialog.findViewById(R.id.btn_Sourceforge);
    btn_Sourceforge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent localIntent = new Intent("android.intent.action.VIEW");
            localIntent.setData(Uri.parse(sourceforgeName));
            startActivity(localIntent);
            dialog.dismiss();
        }
    });

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

    dialog.show();
}

From source file:com.wrmndfzzy.atomize.intro.IntroActivity.java

protected void permissionsDialog() {
    final Dialog pDialog = new Dialog(IntroActivity.this);
    pDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    pDialog.setTitle("Missing Permissions");
    pDialog.setContentView(R.layout.intro_permissions_dialog);
    pDialogConfirm = (Button) pDialog.findViewById(R.id.ipDialogConfirm);
    pDialogConfirm.setOnClickListener(new View.OnClickListener() {
        @Override/*from   w  w  w .ja va2  s .  co  m*/
        public void onClick(View v) {
            pDialog.dismiss();
            IntroActivity.this.finish();
        }
    });
    pDialog.show();
}

From source file:com.greatnowhere.radar.MainRadarActivity.java

private void showAboutDialog() {
    final Dialog d = new Dialog(this);
    d.setContentView(R.layout.about);//from   ww  w  .jav a2  s.c  o m
    d.setTitle(R.string.app_name);
    Button dialogOk = (Button) d.findViewById(R.id.aboutIdButtonOK);
    dialogOk.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            d.dismiss();
        }
    });
    d.show();
}

From source file:com.digitallizard.nicecompass.CompassActivity.java

protected Dialog onCreateDialog(int id) {
    Dialog dialog = null;

    // create a generic select bearing dialog
    dialog = createSelectBearingDialog();

    Button setButton = (Button) dialog.findViewById(R.id.bearingSetButton);
    Button autoButton = (Button) dialog.findViewById(R.id.bearingAutoButton);

    switch (id) {
    case DIALOG_SELECT_LOCKED_BEARING:
        // set the title
        dialog.setTitle(this.getResources().getString(R.string.menu_title_manual_locked_brearing));

        // get a reference to the textview for the callbacks
        //FIXME shouldn't store the reference like this
        lockedBearingEditText = (EditText) dialog.findViewById(R.id.bearingSelectionText);

        // add the appropriate listeners to the dialog buttons
        // add a listener to the set button
        setButton.setOnClickListener(new View.OnClickListener() {
            @Override/* w  w  w .  jav  a2 s . c  om*/
            public void onClick(View view) {
                // get the value and save it as required
                float value = 0;
                try {
                    value = Float.parseFloat(lockedBearingEditText.getText().toString());
                } catch (NumberFormatException e) {
                    // probably a temporary error, just give up for now
                    return;
                }

                // convert the value to a whole number
                value = (float) Math.floor(value);
                // make the value positive
                if (value < 0) {
                    value *= -1f;
                }
                // if the value is out of range, move it to within range
                value = value % 360;
                lockedBearingEditText.setText(Integer.toString((int) value));

                // lock the bearing to the value
                surface.lockBearingTo((int) value);

                // close the dialog
                closeBearingDialog(DIALOG_SELECT_LOCKED_BEARING);
            }
        });

        // add a listener to the auto button
        autoButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                surface.unlockBearing();

                // close the dialog
                closeBearingDialog(DIALOG_SELECT_LOCKED_BEARING);
            }
        });

        break;
    case DIALOG_SELECT_VARIATION:
        // set the title
        dialog.setTitle(this.getResources().getString(R.string.menu_title_manual_variation));

        // get a reference to the textview for the callbacks
        //FIXME shouldn't store the reference like this
        selectVariationEditText = (EditText) dialog.findViewById(R.id.bearingSelectionText);

        // add the appropriate listeners to the dialog buttons
        // add a listener to the set button
        setButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // get the value and save it as required
                float value = 0;
                try {
                    value = Float.parseFloat(selectVariationEditText.getText().toString());
                } catch (NumberFormatException e) {
                    // probably a temporary error, just give up for now
                    return;
                }

                // set the manual declination
                surface.setManualDeclination(value);

                // close the dialog
                closeBearingDialog(DIALOG_SELECT_VARIATION);
            }
        });

        // add a listener to the auto button
        autoButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // disable manual declination
                surface.useAutoDeclination();

                // close the dialog
                closeBearingDialog(DIALOG_SELECT_VARIATION);
            }
        });

        break;
    default:
        dialog = null;
    }
    return dialog;
}

From source file:com.infamous.site.activity.MainActivity.java

public Dialog getChangelog() {
    final Dialog CDialog = new Dialog(MainActivity.this);
    CDialog.setTitle(getResources().getString(R.string.changelog_title));
    CDialog.setContentView(R.layout.changelog);
    CDialog.setCanceledOnTouchOutside(true);
    CDialog.setCancelable(true);//from www. java2  s  . c  o m

    Button Close = (Button) CDialog.findViewById(R.id.close);
    Close.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            CDialog.dismiss();
        }
    });

    return CDialog;
}

From source file:com.kaproduction.malibilgiler.MainActivity.java

private void showHakkindaDialog() {

    final Dialog hakkindaDialog = new Dialog(this);
    hakkindaDialog.setContentView(R.layout.layout_hakkinda);

    TextView openSourceMetin = (TextView) hakkindaDialog.findViewById(R.id.textViewHakkindaOpenSource);
    openSourceMetin.setText(//w  w  w .j av a2  s . c  om
            "Ak Kaynak Ktphaneler :\nJoda Time:\njodatime:joda-time:2.9.5\nJoda-Time is licensed under the business-friendly Apache 2.0 license.");

    TextView hakkindaMetin = (TextView) hakkindaDialog.findViewById(R.id.textViewHakkindaMetin);
    hakkindaMetin.setText("Genel Aklama :\nKullanm olduunuz bu uygulamann ierii "
            + "kullancy bilgilendirmek amacyla dzennmi olup, site ierisinde yer alan hibir bilgi "
            + "ziyaretiler tarafndan tavsiye olarak deerlendirilip hibir karar veya eyleme neden olamaz.  "
            + "Uygulama ierii Gelir daresi Bakanl, Sosyal Gvenlik Kurumu ve Trkiye "
            + "statistik Kurumu gibi eitli kurum ve kurululardan edinilen "
            + "verilerden yararlanlarak hazrlanmtr. "
            + "Uygulamann ierii ile ilgili olarak sz konusu kurumlar ile farkllklar "
            + "bulunmas halinde sz konusu kurumlarn verilerinin esas alnmas gerekmektedir."
            + "Uygulamann ieriinden kaynaklanan hatalardan dolay uygulama sorumlu tutulamaz, "
            + "hibir hukuki veya cezai sorumluluk kabul edilmez.  ");

    Button buttonTamam = (Button) hakkindaDialog.findViewById(R.id.buttonHakkindaOK);
    buttonTamam.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            hakkindaDialog.dismiss();
        }
    });

    hakkindaDialog.show();

}

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

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setContentView(R.layout.eula);

    //load the tabs
    mTabs = (TabHost) dialog.findViewById(android.R.id.tabhost);
    mTabs.setup();//ww  w .ja v a 2 s . c  om

    TabSpec tab_one = mTabs.newTabSpec("eula_tab");
    tab_one.setContent(R.id.eula_body);
    tab_one.setIndicator("EULA");
    mTabs.addTab(tab_one);

    TabSpec tab_two = mTabs.newTabSpec("privacy_tab");
    tab_two.setContent(R.id.priv_body);
    tab_two.setIndicator("Privacy Policy");
    mTabs.addTab(tab_two);

    //work around lack of ability to control tab height from xml completely
    TabWidget tab_widget = (TabWidget) dialog.findViewById(android.R.id.tabs);
    mTabs.getTabWidget().getChildAt(0).getLayoutParams().height = tab_widget.getLayoutParams().height;
    mTabs.getTabWidget().getChildAt(1).getLayoutParams().height = tab_widget.getLayoutParams().height;

    //load the agreements
    mEulaScroll = (ScrollView) dialog.findViewById(R.id.eula_scroll);
    mLoading = (LinearLayout) dialog.findViewById(R.id.loading);
    mEulaBodyView = (TextView) dialog.findViewById(R.id.eula_body);
    mPrivacyBodyView = (TextView) dialog.findViewById(R.id.priv_body);

    mAcceptedCheckbox = (CheckBox) dialog.findViewById(R.id.eula_checkbox);
    mAcceptButton = (Button) dialog.findViewById(R.id.eula_accept);
    mRejectButton = (Button) dialog.findViewById(R.id.eula_reject);
    mEmailButton = (Button) dialog.findViewById(R.id.eula_email);
    mDismissButton = (Button) dialog.findViewById(R.id.eula_dismiss);
    mEulaAcceptArea = (LinearLayout) dialog.findViewById(R.id.eula_accept_area);

    mAcceptedCheckbox.setOnCheckedChangeListener(new OnAcceptToggle());
    mAcceptButton.setOnClickListener(new OnAccept());
    mRejectButton.setOnClickListener(new OnReject());
    mEmailButton.setOnClickListener(new OnEmail());
    mDismissButton.setOnClickListener(new OnDismiss());

    if (!mRequired) {
        mEulaAcceptArea.setVisibility(View.GONE);
        mAcceptButton.setVisibility(View.GONE);
        mRejectButton.setVisibility(View.GONE);
        mDismissButton.setVisibility(View.VISIBLE);
    } else {
        mEulaAcceptArea.setVisibility(View.VISIBLE);
        mAcceptButton.setVisibility(View.VISIBLE);
        mRejectButton.setVisibility(View.VISIBLE);
        mDismissButton.setVisibility(View.GONE);
    }

    mAcceptButton.setEnabled(mAcceptedCheckbox.isChecked());
    dialog.setTitle("Musubi Usage Agreements");
    dialog.setOnKeyListener(new OnKey());

    new AgreementLoader().execute();
    return dialog;
}

From source file:com.ivalentin.margolariak.SettingsLayout.java

private void showDialog(String title, String text) {
    //Create the dialog
    final Dialog dialog = new Dialog(getActivity());

    //Set up dialog window
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_settings);

    //Set the custom dialog components - text, image and button
    TextView tvTitle = (TextView) dialog.findViewById(R.id.tv_dialog_settings_title);
    WebView wvText = (WebView) dialog.findViewById(R.id.wv_dialog_settings_text);

    if (Build.VERSION.SDK_INT >= 19) {
        wvText.setLayerType(View.LAYER_TYPE_HARDWARE, null);
    } else {/*from  w ww  .j  av a  2 s  .  c o m*/
        wvText.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    Button btClose = (Button) dialog.findViewById(R.id.bt_dialog_settings_close);

    //Set text
    tvTitle.setText(title);
    wvText.loadDataWithBaseURL(null, text, "text/html", "utf-8", null);

    //Set close button
    btClose.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    //Set parameters
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.MATCH_PARENT;
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
    lp.gravity = Gravity.CENTER;
    lp.dimAmount = 0.4f;
    dialog.getWindow().setAttributes(lp);

    //Show dialog
    dialog.show();

}

From source file:io.spw.hello.SectionsPagerAdapter.java

public void showMatchDialog() throws JSONException, ParseException {

    final Dialog dialog = new Dialog(mActivity);
    dialog.setContentView(R.layout.dialog_match_made);
    dialog.setTitle("An introduction is the essence of possibility");

    // find views
    TextView userName0 = (TextView) dialog.findViewById(R.id.userName0);
    TextView userInfo0 = (TextView) dialog.findViewById(R.id.userInfo0);
    TextView userName1 = (TextView) dialog.findViewById(R.id.userName1);
    TextView userInfo1 = (TextView) dialog.findViewById(R.id.userInfo1);
    TextView userName2 = (TextView) dialog.findViewById(R.id.userName2);
    TextView userInfo2 = (TextView) dialog.findViewById(R.id.userInfo2);
    Button helloButton = (Button) dialog.findViewById(R.id.dialog_hello_button);

    // get member users
    JSONArray userIds = currentUser.getJSONArray(ParseConstants.KEY_MEMBER_IDS);
    ParseRelation<ParseUser> groupMembersRelation = currentUser
            .getRelation(ParseConstants.KEY_GROUP_MEMBERS_RELATION);
    List<ParseUser> users = new ArrayList<>();
    for (int i = 0; i < userIds.length(); i++) {
        if (!currentUser.getObjectId().equals(userIds.getString(i))) {
            ParseUser user = ParseUser.getQuery().get(userIds.getString(i));
            users.add(user);/*from   ww w.j  a  va 2s  .  c o m*/
            groupMembersRelation.add(user);
        }
    }

    // set text
    userName0.setText(users.get(0).getString(ParseConstants.KEY_FIRST_NAME));
    userInfo0.setText(users.get(0).getString(ParseConstants.KEY_AGE) + " // "
            + (users.get(0).getString(ParseConstants.KEY_HOMETOWN)));

    userName1.setText(users.get(1).getString(ParseConstants.KEY_FIRST_NAME));
    userInfo1.setText(users.get(1).getString(ParseConstants.KEY_AGE) + " // "
            + (users.get(1).getString(ParseConstants.KEY_HOMETOWN)));

    userName2.setText(users.get(2).getString(ParseConstants.KEY_FIRST_NAME));
    userInfo2.setText(users.get(2).getString(ParseConstants.KEY_AGE) + " // "
            + (users.get(2).getString(ParseConstants.KEY_HOMETOWN)));

    // set button
    helloButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            currentUser.put(ParseConstants.KEY_MATCH_DIALOG_SEEN, true);
            currentUser.saveInBackground();
            if (mFirstFragment instanceof ThisWeekendFragment) {
                switchToGroupChatFragment();
            }
            dialog.dismiss();
        }
    });

    dialog.show();
}