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:pulseanddecibels.jp.yamatenki.activity.SplashActivity.java

private void displayUserLicenseAgreement() {
    final Dialog dialog = new Dialog(SplashActivity.this);
    //        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_license_agreement);
    dialog.setTitle(getString(R.string.text_license_agreement_title));
    dialog.setCanceledOnTouchOutside(false);
    Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.yama_brown));
    dialog.getWindow().setBackgroundDrawable(d);
    dialog.show();/*from  w  w  w.j a va 2s  .com*/
    licenseAgreementDialogOpen = true;
    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            if (!agreeButtonPressed) {
                licenseAgreementDialogOpen = false;
                settings.setAgreedToLicense(false);
                if (!databaseTaskRunning) {
                    finish();
                }
            }
        }
    });
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            licenseAgreementDialogOpen = false;
            settings.setAgreedToLicense(false);
            if (!databaseTaskRunning) {
                finish();
            }
        }
    });

    final Button agreeButton = (Button) dialog.findViewById(R.id.agree_button);
    agreeButton.setEnabled(false);
    agreeButton.setAlpha(.5f);
    agreeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            settings.setAgreedToLicense(true);
            agreeButtonPressed = true;
            dialog.dismiss();
            if (!databaseTaskRunning) {
                startMainActivity();
            }
        }
    });

    final CheckBox agreementCheckbox = (CheckBox) dialog.findViewById(R.id.agreement_checkbox);
    agreementCheckbox.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            CheckBox checkbox = (CheckBox) v;
            if (checkbox.isChecked()) {
                agreeButton.setAlpha(1.0f);
                agreeButton.setEnabled(true);
            } else {
                agreeButton.setAlpha(.5f);
                agreeButton.setEnabled(false);
            }
        }
    });

    TextView agreementLabel = (TextView) dialog.findViewById(R.id.agreement_label);
    agreementLabel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            agreementCheckbox.setChecked(!agreementCheckbox.isChecked());
            if (agreementCheckbox.isChecked()) {
                agreeButton.setAlpha(1.0f);
                agreeButton.setEnabled(true);
            } else {
                agreeButton.setAlpha(.5f);
                agreeButton.setEnabled(false);
            }
        }
    });
}

From source file:reportsas.com.formulapp.Formulario.java

public void CapturaF() {
    if (parametroCam == null) {

        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(intent, 1);

    } else {// ww w . ja v  a  2s .co  m

        final Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.dialog_imagen);
        dialog.setTitle("Captura de Formulario");
        byte[] decodedByte = Base64.decode(parametroCam.getValor(), 0);

        ImageView imageview = (ImageView) dialog.findViewById(R.id.ImaVcaptura);
        Button Button1 = (Button) dialog.findViewById(R.id.NuevaToma);
        Button Button2 = (Button) dialog.findViewById(R.id.btn_cerrar);

        imageview.setImageBitmap(BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length));
        Button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(intent, 1);
                dialog.dismiss();
            }
        });

        Button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                dialog.dismiss();
            }
        });

        dialog.show();

    }

}

From source file:com.dsdar.thosearoundme.TeamViewActivity.java

@Override
public boolean onMarkerClick(final Marker theMarker) {
    if (theMarker.equals(MyAppConstants.myMarker)) {
        return false;
    }//from   w  ww.ja v  a  2 s .c o  m

    // Normal Marker
    if (!theMarker.equals(MyAppConstants.myMarker) && (theMarker.getTitle() != null)) {

        final Dialog aMemberDialog = new Dialog(TeamViewActivity.this, R.style.DialogSlideAnim);
        aMemberDialog.setContentView(R.layout.member_dialog);

        TextView aMemberTextName = (TextView) aMemberDialog.findViewById(R.id.tvMemberName);
        Button aTextButton = (Button) aMemberDialog.findViewById(R.id.bMemberText);
        Button aPushButton = (Button) aMemberDialog.findViewById(R.id.bMemberPush);
        Button aCallButton = (Button) aMemberDialog.findViewById(R.id.bMemberCall);
        Button aRemoveButton = (Button) aMemberDialog.findViewById(R.id.bMemberRemove);

        String[] res = theMarker.getTitle().split("~");
        String title = res[0];
        final String phone = res[1];

        aMemberTextName.setText("Say hello to " + title + "!");
        aMemberDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
        aMemberDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        aMemberDialog.getWindow().setGravity(Gravity.BOTTOM);
        aMemberDialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        aMemberDialog.show();
        ImageView aCancelButton = (ImageView) aMemberDialog.findViewById(R.id.bCancelMemberDialog);
        aCancelButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                aMemberDialog.dismiss();
            }
        });

        aTextButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Uri sms_uri = Uri.parse("smsto:" + phone);
                Intent sms_intent = new Intent(Intent.ACTION_SENDTO, sms_uri);
                startActivity(sms_intent);
            }
        });

        // aPushButton.setOnClickListener(new OnClickListener() {
        // public void onClick(View v) {
        // // startActivity(new Intent(Intent.ACTION_VIEW,
        // // Uri.parse("sms:"
        // // + theMarker.getSnippet())));
        // }
        // });

        aCallButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent callIntent = new Intent(Intent.ACTION_DIAL);
                callIntent.setData(Uri.parse("tel:" + phone));
                startActivity(callIntent);
            }
        });

        // aRemoveButton.setOnClickListener(new OnClickListener() {
        // public void onClick(View v) {
        // }
        // });
    } else {

        StickyMarkerBehaviorDialog dialog = new StickyMarkerBehaviorDialog(this);
        dialog.show();
    }

    return true;
}

From source file:com.owncloud.android.ui.adapter.FileListListAdapter.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    View view = convertView;//  w  ww  .  ja  va2  s. c  o  m
    if (view == null) {
        LayoutInflater inflator = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflator.inflate(R.layout.list_item, null);
    }

    if (mFiles != null && mFiles.size() > position) {
        OCFile file = mFiles.get(position);
        TextView fileName = (TextView) view.findViewById(R.id.Filename);
        String name = file.getFileName();
        if (dataSourceShareFile == null)
            dataSourceShareFile = new DbShareFile(mContext);

        Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
        String[] accountNames = account.name.split("@");

        if (accountNames.length > 2) {
            accountName = accountNames[0] + "@" + accountNames[1];
            url = accountNames[2];
        }
        Map<String, String> fileSharers = dataSourceShareFile.getUsersWhoSharedFilesWithMe(accountName);
        TextView sharer = (TextView) view.findViewById(R.id.sharer);
        ImageView shareButton = (ImageView) view.findViewById(R.id.shareItem);
        fileName.setText(name);
        ImageView fileIcon = (ImageView) view.findViewById(R.id.imageView1);
        fileIcon.setImageResource(DisplayUtils.getResourceId(file.getMimetype()));
        ImageView localStateView = (ImageView) view.findViewById(R.id.imageView2);
        FileDownloaderBinder downloaderBinder = mTransferServiceGetter.getFileDownloaderBinder();
        FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder();
        if (fileSharers.size() != 0 && (!file.equals("Shared") && file.getRemotePath().contains("Shared"))) {
            if (fileSharers.containsKey(name)) {
                sharer.setText(fileSharers.get(name));
                fileSharers.remove(name);
            } else {
                sharer.setText(" ");
            }
        } else {
            sharer.setText(" ");
        }

        if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) {
            localStateView.setImageResource(R.drawable.downloading_file_indicator);
            localStateView.setVisibility(View.VISIBLE);
        } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) {
            localStateView.setImageResource(R.drawable.uploading_file_indicator);
            localStateView.setVisibility(View.VISIBLE);
        } else if (file.isDown()) {
            localStateView.setImageResource(R.drawable.local_file_indicator);
            localStateView.setVisibility(View.VISIBLE);
        } else {
            localStateView.setVisibility(View.INVISIBLE);
        }

        TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);
        TextView lastModV = (TextView) view.findViewById(R.id.last_mod);
        ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);
        shareButton.setOnClickListener(new OnClickListener() {
            String shareStatusDisplay;
            int flagShare = 0;

            @Override
            public void onClick(View v) {
                final Dialog dialog = new Dialog(mContext);
                final OCFile fileToBeShared = (OCFile) getItem(position);
                final ArrayAdapter<String> shareWithFriends;
                final ArrayAdapter<String> shareAdapter;
                final String filePath;
                sharedWith = new ArrayList<String>();
                dataSource = new DbFriends(mContext);
                dataSourceShareFile = new DbShareFile(mContext);
                dialog.setContentView(R.layout.share_file_with);
                dialog.setTitle("Share");
                Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
                String[] accountNames = account.name.split("@");

                if (accountNames.length > 2) {
                    accountName = accountNames[0] + "@" + accountNames[1];
                    url = accountNames[2];
                }

                final AutoCompleteTextView textView = (AutoCompleteTextView) dialog
                        .findViewById(R.id.autocompleteshare);
                Button shareBtn = (Button) dialog.findViewById(R.id.ShareBtn);
                Button doneBtn = (Button) dialog.findViewById(R.id.ShareDoneBtn);
                final ListView listview = (ListView) dialog.findViewById(R.id.alreadySharedWithList);

                textView.setThreshold(2);
                final String itemType;

                filePath = "files" + String.valueOf(fileToBeShared.getRemotePath());
                final String fileName = fileToBeShared.getFileName();
                final String fileRemotePath = fileToBeShared.getRemotePath();
                if (dataSourceShareFile == null)
                    dataSourceShareFile = new DbShareFile(mContext);
                sharedWith = dataSourceShareFile.getUsersWithWhomIhaveSharedFile(fileName, fileRemotePath,
                        accountName, String.valueOf(1));
                shareAdapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1,
                        sharedWith);
                listview.setAdapter(shareAdapter);
                final String itemSource;
                if (fileToBeShared.isDirectory()) {
                    itemType = "folder";
                    int lastSlashInFolderPath = filePath.lastIndexOf('/');
                    itemSource = filePath.substring(0, lastSlashInFolderPath);
                } else {
                    itemType = "file";
                    itemSource = filePath;
                }

                //Permissions disabled with friends app
                ArrayList<String> friendList = dataSource.getFriendList(accountName);
                dataSource.close();
                shareWithFriends = new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1,
                        friendList);
                textView.setAdapter(shareWithFriends);
                textView.setFocusableInTouchMode(true);
                dialog.show();
                textView.setOnItemClickListener(new OnItemClickListener() {

                    @Override
                    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

                    }
                });
                final Handler finishedHandler = new Handler() {
                    @Override
                    public void handleMessage(Message msg) {
                        shareAdapter.notifyDataSetChanged();
                        Toast.makeText(mContext, shareStatusDisplay, Toast.LENGTH_SHORT).show();

                    }
                };
                shareBtn.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        final String shareWith = textView.getText().toString();

                        if (shareWith.equals("")) {
                            textView.setHint("Share With");
                            Toast.makeText(mContext,
                                    "Please enter the friends name with whom you want to share",
                                    Toast.LENGTH_SHORT).show();
                        } else if (sharedWith.contains(shareWith)) {
                            textView.setHint("Share With");
                            Toast.makeText(mContext, "You have shared the file with that person",
                                    Toast.LENGTH_SHORT).show();
                        } else {

                            textView.setText("");
                            Runnable runnable = new Runnable() {
                                @Override
                                public void run() {
                                    HttpPost post = new HttpPost(
                                            "http://" + url + "/owncloud/androidshare.php");
                                    final ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();

                                    params.add(new BasicNameValuePair("itemType", itemType));
                                    params.add(new BasicNameValuePair("itemSource", itemSource));
                                    params.add(new BasicNameValuePair("shareType", shareType));
                                    params.add(new BasicNameValuePair("shareWith", shareWith));
                                    params.add(new BasicNameValuePair("permission", permissions));
                                    params.add(new BasicNameValuePair("uidOwner", accountName));
                                    HttpEntity entity;
                                    String shareSuccess = "false";
                                    try {
                                        entity = new UrlEncodedFormEntity(params, "utf-8");
                                        HttpClient client = new DefaultHttpClient();
                                        post.setEntity(entity);
                                        HttpResponse response = client.execute(post);

                                        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                                            HttpEntity entityresponse = response.getEntity();
                                            String jsonentity = EntityUtils.toString(entityresponse);
                                            JSONObject obj = new JSONObject(jsonentity);
                                            shareSuccess = obj.getString("SHARE_STATUS");
                                            flagShare = 1;
                                            if (shareSuccess.equals("true")) {
                                                dataSourceShareFile.putNewShares(fileName, fileRemotePath,
                                                        accountName, shareWith);
                                                sharedWith.add(shareWith);
                                                shareStatusDisplay = "File share succeeded";
                                            } else if (shareSuccess.equals("INVALID_FILE")) {
                                                shareStatusDisplay = "File you are trying to share does not exist";
                                            } else if (shareSuccess.equals("INVALID_SHARETYPE")) {
                                                shareStatusDisplay = "File Share type is invalid";
                                            } else {
                                                shareStatusDisplay = "Share did not succeed. Please check your internet connection";
                                            }

                                            finishedHandler.sendEmptyMessage(flagShare);

                                        }
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }

                                }
                            };
                            new Thread(runnable).start();

                        }

                        if (flagShare == 1) {
                        }

                    }

                });
                doneBtn.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        dialog.dismiss();
                        //dataSourceShareFile.close();
                    }
                });
            }

        });
        //dataSourceShareFile.close();
        if (!file.isDirectory()) {
            fileSizeV.setVisibility(View.VISIBLE);
            fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
            lastModV.setVisibility(View.VISIBLE);
            lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
            // this if-else is needed even thoe fav icon is visible by default
            // because android reuses views in listview
            if (!file.keepInSync()) {
                view.findViewById(R.id.imageView3).setVisibility(View.GONE);
            } else {
                view.findViewById(R.id.imageView3).setVisibility(View.VISIBLE);
            }

            ListView parentList = (ListView) parent;
            if (parentList.getChoiceMode() == ListView.CHOICE_MODE_NONE) {
                checkBoxV.setVisibility(View.GONE);
            } else {
                if (parentList.isItemChecked(position)) {
                    checkBoxV.setImageResource(android.R.drawable.checkbox_on_background);
                } else {
                    checkBoxV.setImageResource(android.R.drawable.checkbox_off_background);
                }
                checkBoxV.setVisibility(View.VISIBLE);
            }

        } else {

            fileSizeV.setVisibility(View.VISIBLE);
            fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
            lastModV.setVisibility(View.VISIBLE);
            lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
            checkBoxV.setVisibility(View.GONE);
            view.findViewById(R.id.imageView3).setVisibility(View.GONE);
        }
    }

    return view;
}

From source file:in.shick.diode.mail.InboxListActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    Dialog dialog;
    ProgressDialog pdialog;//from w  ww  . j a va 2 s  . c  o m
    switch (id) {
    case Constants.DIALOG_LOGIN:
        dialog = new LoginDialog(this, mSettings, true) {
            @Override
            public void onLoginChosen(String user, String password) {
                removeDialog(Constants.DIALOG_LOGIN);
                new MyLoginTask(user, password).execute();
            }
        };
        break;

    case Constants.DIALOG_REPLY:
        dialog = new Dialog(this, mSettings.getDialogTheme());
        dialog.setContentView(R.layout.compose_reply_dialog);
        final EditText replyBody = (EditText) dialog.findViewById(R.id.body);
        final Button replySaveButton = (Button) dialog.findViewById(R.id.reply_save_button);
        final Button replyCancelButton = (Button) dialog.findViewById(R.id.reply_cancel_button);
        replySaveButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (mReplyTargetName != null) {
                    new MessageReplyTask(mReplyTargetName).execute(replyBody.getText().toString());
                    removeDialog(Constants.DIALOG_REPLY);
                } else {
                    Common.showErrorToast("Error replying. Please try again.", Toast.LENGTH_SHORT,
                            InboxListActivity.this);
                }
            }
        });
        replyCancelButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                removeDialog(Constants.DIALOG_REPLY);
            }
        });
        break;
    // "Please wait"
    case Constants.DIALOG_LOGGING_IN:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Logging in...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    case Constants.DIALOG_REPLYING:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Sending reply...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;

    default:
        throw new IllegalArgumentException("Unexpected dialog id " + id);
    }
    return dialog;
}

From source file:com.msopentech.applicationgateway.EnterpriseBrowserActivity.java

/**
 * Shows dialog enabling user to bookmark current (by default) or any other page.
 * /*from  w  w w.  j  av  a 2 s  .c o m*/
 * @param v View this method is attached to.
 */
public void showAddBookmarkDialog(View v) {
    try {
        final Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.create_bookmark_dialog);
        dialog.setTitle(getString(R.string.bookmark_dialog_title));
        dialog.setCanceledOnTouchOutside(false);

        TextView cancelButton = (TextView) dialog.findViewById(R.id.create_bookmark_cancel);
        TextView saveButton = (TextView) dialog.findViewById(R.id.create_bookmark_ok);

        OnClickListener listener = new OnClickListener() {
            public void onClick(View v) {
                switch (v.getId()) {
                case R.id.create_bookmark_cancel: {
                    dialog.dismiss();
                    break;
                }
                case R.id.create_bookmark_ok: {
                    String name = ((EditText) dialog.findViewById(R.id.create_bookmark_name)).getText()
                            .toString();
                    String address = ((EditText) dialog.findViewById(R.id.create_bookmark_url)).getText()
                            .toString();

                    if (null != name && !(name.contentEquals("")) && null != address
                            && !(address.contentEquals(""))) {
                        PersistenceManager.addRecord(PersistenceManager.ContentType.BOOKMARKS,
                                new URLInfo(address, name));
                    }

                    dialog.dismiss();
                    break;
                }
                }
            }
        };

        cancelButton.setOnClickListener(listener);
        saveButton.setOnClickListener(listener);

        EditText name = (EditText) dialog.findViewById(R.id.create_bookmark_name);
        EditText address = (EditText) dialog.findViewById(R.id.create_bookmark_url);

        name.setText(mActiveWebView.getTitle());
        address.setText(mUrlEditTextView.getText());

        dialog.show();
    } catch (final Exception e) {
        Utility.showAlertDialog(EnterpriseBrowserActivity.class.getSimpleName()
                + ".showAddBookmarkDialog(): Failed. " + e.toString(), EnterpriseBrowserActivity.this);
    }
}

From source file:com.andrewshu.android.reddit.threads.ThreadsListActivity.java

@Override
protected void onPrepareDialog(int id, Dialog dialog) {
    super.onPrepareDialog(id, dialog);

    switch (id) {
    case Constants.DIALOG_LOGIN:
        if (mSettings.getUsername() != null) {
            final TextView loginUsernameInput = (TextView) dialog.findViewById(R.id.login_username_input);
            loginUsernameInput.setText(mSettings.getUsername());
        }//from   w ww. ja v a  2  s  . c om
        final TextView loginPasswordInput = (TextView) dialog.findViewById(R.id.login_password_input);
        loginPasswordInput.setText("");
        break;

    case Constants.DIALOG_THREAD_CLICK:
        if (mVoteTargetThing == null)
            break;
        fillThreadClickDialog(dialog, mVoteTargetThing, mSettings, mThreadClickDialogOnClickListenerFactory);
        break;

    case Constants.DIALOG_SORT_BY:
        ((AlertDialog) dialog).getListView().setItemChecked(getSelectedSortBy(), true);
        break;
    case Constants.DIALOG_SORT_BY_NEW:
        ((AlertDialog) dialog).getListView().setItemChecked(getSelectedSortByNew(), true);
        break;
    case Constants.DIALOG_SORT_BY_CONTROVERSIAL:
        ((AlertDialog) dialog).getListView().setItemChecked(getSelectedSortByControversial(), true);
        break;
    case Constants.DIALOG_SORT_BY_TOP:
        ((AlertDialog) dialog).getListView().setItemChecked(getSelectedSortByTop(), true);
        break;

    default:
        // No preparation based on app state is required.
        break;
    }
}

From source file:com.alivenet.dmv.driverapplication.fragment.MyAccount.java

public void showActionSheet() {

    LayoutInflater inflater = LayoutInflater.from(getActivity());
    final Dialog myDialog = new Dialog(getActivity(), android.R.style.Theme_Translucent_NoTitleBar);
    myDialog.setCanceledOnTouchOutside(true);
    myDialog.getWindow().setLayout(AbsoluteLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    myDialog.getWindow().setGravity(Gravity.BOTTOM);
    myDialog.getWindow().getAttributes().windowAnimations = R.anim.slide_up;
    WindowManager.LayoutParams lp = myDialog.getWindow().getAttributes();
    lp.dimAmount = 0.75f;/*  w  w w  .  j a v a2  s.c o  m*/
    myDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    myDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    myDialog.getWindow();

    View dialoglayout = inflater.inflate(R.layout.dialog_profile_actionsheet, null);
    myDialog.setContentView(dialoglayout);
    TextView mTvTakeFromCamera = (TextView) myDialog.findViewById(R.id.tvTakeFromCamera);
    TextView mTvTakeFromLibrary = (TextView) myDialog.findViewById(R.id.tvTakeFromLibrary);

    long timestamp = System.currentTimeMillis();
    AppData.getSingletonObject().setmFileTemp(getActivity(), "" + timestamp);
    mTvTakeFromCamera.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            myDialog.dismiss();
            takePicture(getActivity());

        }

    });

    mTvTakeFromLibrary.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            myDialog.dismiss();
            openGallery(getActivity());
        }

    });

    TextView tvCancel = (TextView) myDialog.findViewById(R.id.tvCancel);

    tvCancel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            myDialog.dismiss();
        }

    });

    try {
        myDialog.show();
    } catch (WindowManager.BadTokenException e) {

        Log.e("", "View not attached.");
    } catch (Exception e) {

        e.printStackTrace();
    }
}

From source file:nf.frex.android.FrexActivity.java

private void prepareColorsDialog(final Dialog dialog) {

    //Log.d(TAG, "prepareColorsDialog() entered");

    getColorSchemes();/*from  w w  w.  j  a v a 2  s.com*/

    //Log.d(TAG, "prepareColorsDialog: new bitmaps are being created");
    Bitmap[] colorSchemeIcons = new Bitmap[colorSchemes.getSize()];
    for (int i = 0; i < colorSchemeIcons.length; i++) {
        ColorScheme colorScheme = colorSchemes.getValue(i);
        colorSchemeIcons[i] = colorScheme.getGradientIcon();
    }

    int checkedIndex = Registries.colorSchemes.getIndex(view.getColorSchemeId());
    //Log.d(TAG, "prepareColorsDialog: checkedIndex = " + checkedIndex);
    final Spinner colorTableSpinner = (Spinner) dialog.findViewById(R.id.color_table_spinner);
    colorTableSpinner.setAdapter(new ImageArrayAdapter(this, 0, colorSchemeIcons));
    colorTableSpinner.setSelection(checkedIndex, false);
    colorTableSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View spinnerView, int position, long id) {
            view.setColorSchemeId(Registries.colorSchemes.getId(position));
            view.setColorScheme(Registries.colorSchemes.getValue(position));
            view.recomputeColors();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    final SeekBar colorFactorSeekBar = (SeekBar) dialog.findViewById(R.id.color_gain_seek_bar);
    final double colorFactorMin = -3.0;
    final double colorFactorMax = 2.0;
    final SeekBarConfigurer colorFactorSeekBarConfigurer = SeekBarConfigurer.create(colorFactorSeekBar,
            colorFactorMin, colorFactorMax, true, view.getColorGain());
    colorFactorSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            view.setColorGain((float) colorFactorSeekBarConfigurer.getValue());
            view.recomputeColors();
        }
    });

    final SeekBar colorBiasSeekBar = (SeekBar) dialog.findViewById(R.id.color_offset_seek_bar);
    final double colorBiasMin = 0;
    final double colorBiasMax = 1024;
    final SeekBarConfigurer colorBiasSeekBarConfigurer = SeekBarConfigurer.create(colorBiasSeekBar,
            colorBiasMin, colorBiasMax, false, view.getColorOffset());
    colorBiasSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            view.setColorOffset((float) colorBiasSeekBarConfigurer.getValue());
            view.recomputeColors();
        }
    });

    final CheckBox colorRepeatCheckBox = (CheckBox) dialog.findViewById(R.id.color_repeat);
    colorRepeatCheckBox.setChecked(view.isColorRepeat());
    colorRepeatCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            view.setColorRepeat(isChecked);
            view.recomputeColors();
        }
    });

    Button randomButton = (Button) dialog.findViewById(R.id.random_button);
    randomButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            colorTableSpinner.setSelection((int) (Math.random() * colorSchemes.getSize()));
            colorFactorSeekBarConfigurer.setRandomValue();
            colorBiasSeekBarConfigurer.setRandomValue();
            view.recomputeColors();
        }
    });

    Button getPalFromImgButton = (Button) dialog.findViewById(R.id.get_pal_from_img_button);
    getPalFromImgButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
            photoPickerIntent.setType("image/*");
            dialog.dismiss();
            startActivityForResult(photoPickerIntent, SELECT_PICTURE_REQUEST_CODE);
        }
    });

    //Log.d(TAG, "prepareColorsDialog() exited");
}