Example usage for android.app Dialog Dialog

List of usage examples for android.app Dialog Dialog

Introduction

In this page you can find the example usage for android.app Dialog Dialog.

Prototype

public Dialog(@NonNull Context context) 

Source Link

Document

Creates a dialog window that uses the default dialog theme.

Usage

From source file:com.beza.briver.fragments.ProfileFragment.java

private void showDocumentsAttachmentCustomDialog() {
    final Dialog customAttachmentsDialog = new Dialog(getActivity());
    customAttachmentsDialog.setContentView(R.layout.layout_custom_attachment_dialog);

    customAttachmentsDialog.setCancelable(false);
    customAttachmentsDialog.setTitle("Attach Documents");

    Button buttonNo = (Button) customAttachmentsDialog.findViewById(R.id.btn_driver_hire_dialog_cancel);
    buttonNo.setOnClickListener(new View.OnClickListener() {
        @Override//from  w w  w .  j a v  a2 s .c om
        public void onClick(View v) {
            customAttachmentsDialog.dismiss();
        }
    });

    Button buttonYes = (Button) customAttachmentsDialog.findViewById(R.id.btn_driver_hire_dialog_hire);
    buttonYes.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (imageChanged) {
                customAttachmentsDialog.dismiss();
                etProfileAttachments.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.ic_edit_text_attachment,
                        0, R.mipmap.ic_edit_text_add_image, 0);
                File destination = new File(Environment.getExternalStorageDirectory() + File.separator
                        + "Android/data" + File.separator + AppGlobals.getContext().getPackageName());
                for (int i = 0; i < 3; i++) {
                    if (hashMapTemp.containsKey(i)) {
                        File file = new File(destination, i + ".jpg");
                        file.delete();
                        File from = new File(destination, i + "temp" + ".jpg");
                        File to = new File(destination, i + ".jpg");
                        from.renameTo(to);
                    }
                }

                Log.i("images array", String.valueOf(imagePathsArray));
                imageChanged = false;
            } else {
                Toast.makeText(getActivity(), "No Change to submit", Toast.LENGTH_SHORT).show();
            }
        }
    });

    ibPhotoOne = (ImageButton) customAttachmentsDialog.findViewById(R.id.ib_photo_one);
    ibPhotoTwo = (ImageButton) customAttachmentsDialog.findViewById(R.id.ib_photo_two);
    ibPhotoThree = (ImageButton) customAttachmentsDialog.findViewById(R.id.ib_photo_three);

    ibPhotoOne.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ibPosition = 0;
            Helpers.AlertDialogWithPositiveNegativeFunctionsNeutralButton(getActivity(), "License Front",
                    "Select an option to add photo", "Camera", "Gallery", "Cancel", openCameraIntent,
                    openGalleryIntent);
        }
    });

    ibPhotoTwo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ibPosition = 1;
            Helpers.AlertDialogWithPositiveNegativeFunctionsNeutralButton(getActivity(), "License Back",
                    "Select an option to add photo", "Camera", "Gallery", "Cancel", openCameraIntent,
                    openGalleryIntent);
        }
    });

    ibPhotoThree.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ibPosition = 2;
            Helpers.AlertDialogWithPositiveNegativeFunctionsNeutralButton(getActivity(), "Police Verification",
                    "Select an option to add photo", "Camera", "Gallery", "Cancel", openCameraIntent,
                    openGalleryIntent);
        }
    });

    ibPhotoOne.setBackgroundDrawable(null);
    ibPhotoOne.setImageBitmap(Helpers.getCroppedBitmap(
            Helpers.getResizedBitmapToDisplay(BitmapFactory.decodeFile(hashMap.get(0)), 120)));
    ibPhotoTwo.setBackgroundDrawable(null);
    ibPhotoTwo.setImageBitmap(Helpers.getCroppedBitmap(
            Helpers.getResizedBitmapToDisplay(BitmapFactory.decodeFile(hashMap.get(1)), 120)));
    ibPhotoThree.setBackgroundDrawable(null);
    ibPhotoThree.setImageBitmap(Helpers.getCroppedBitmap(
            Helpers.getResizedBitmapToDisplay(BitmapFactory.decodeFile(hashMap.get(2)), 120)));
    customAttachmentsDialog.show();
}

From source file:com.adithya321.sharesanalysis.fragments.PurchaseShareFragment.java

private void setRecyclerViewAdapter() {
    sharesList = databaseHandler.getShares();
    purchaseList = databaseHandler.getPurchases();

    if (sharesList.size() < 1) {
        emptyTV.setVisibility(View.VISIBLE);
        arrow.setVisibility(View.VISIBLE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            if (getResources().getConfiguration().orientation == 1) {
                arrow.setBackground(getResources().getDrawable(R.drawable.curved_line_vertical));
            } else {
                arrow.setBackground((getResources().getDrawable(R.drawable.curved_line_horizontal)));
            }/* w ww  . j a v  a2  s  .c  o  m*/
        }
    } else {
        emptyTV.setVisibility(View.GONE);
        arrow.setVisibility(View.GONE);
    }

    PurchaseShareAdapter purchaseAdapter = new PurchaseShareAdapter(getContext(), purchaseList);
    purchaseAdapter.setOnItemClickListener(new PurchaseShareAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(View itemView, int position) {
            final Purchase purchase = purchaseList.get(position);

            final Dialog dialog = new Dialog(getContext());
            dialog.setTitle("Edit Share Purchase");
            dialog.setContentView(R.layout.dialog_add_share_purchase);
            dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.WRAP_CONTENT);
            dialog.show();

            RadioButton newRB = (RadioButton) dialog.findViewById(R.id.radioBtn_new);
            RadioButton existingRB = (RadioButton) dialog.findViewById(R.id.radioBtn_existing);
            AutoCompleteTextView name = (AutoCompleteTextView) dialog.findViewById(R.id.share_name);
            newRB.setVisibility(View.GONE);
            existingRB.setChecked(true);
            name.setVisibility(View.GONE);

            final Spinner spinner = (Spinner) dialog.findViewById(R.id.existing_spinner);
            ArrayList<String> shares = new ArrayList<>();
            int pos = 0;
            for (int i = 0; i < sharesList.size(); i++) {
                shares.add(sharesList.get(i).getName());
                if (sharesList.get(i).getName().equals(purchase.getName()))
                    pos = i;
            }
            ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(),
                    android.R.layout.simple_spinner_item, shares);
            spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner.setAdapter(spinnerAdapter);
            spinner.setSelection(pos);
            spinner.setVisibility(View.VISIBLE);

            final EditText quantity = (EditText) dialog.findViewById(R.id.no_of_shares);
            final EditText price = (EditText) dialog.findViewById(R.id.buying_price);
            quantity.setText(String.valueOf(purchase.getQuantity()));
            price.setText(String.valueOf(purchase.getPrice()));

            Calendar calendar = Calendar.getInstance();
            calendar.setTime(purchase.getDate());
            year_start = calendar.get(Calendar.YEAR);
            month_start = calendar.get(Calendar.MONTH) + 1;
            day_start = calendar.get(Calendar.DAY_OF_MONTH);
            final Button selectDate = (Button) dialog.findViewById(R.id.select_date);
            selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/")
                    .append(year_start));
            selectDate.setOnClickListener(PurchaseShareFragment.this);

            Button addPurchaseBtn = (Button) dialog.findViewById(R.id.add_purchase_btn);
            addPurchaseBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Purchase p = new Purchase();
                    p.setId(purchase.getId());

                    String stringStartDate = year_start + " " + month_start + " " + day_start;
                    DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH);
                    try {
                        Date date = format.parse(stringStartDate);
                        p.setDate(date);
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    try {
                        p.setQuantity(Integer.parseInt(quantity.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Number of Shares", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    try {
                        p.setPrice(Double.parseDouble(price.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Buying Price", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    p.setType("buy");
                    p.setName(spinner.getSelectedItem().toString());
                    databaseHandler.updatePurchase(p);
                    setRecyclerViewAdapter();
                    dialog.dismiss();
                }
            });
        }
    });
    sharePurchasesRecyclerView.setHasFixedSize(true);
    sharePurchasesRecyclerView.setAdapter(purchaseAdapter);
    sharePurchasesRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
}

From source file:com.eyekabob.util.EyekabobHelper.java

public static Dialog createAboutDialog(Context context) {
    final Dialog dialog = new Dialog(context);
    dialog.setContentView(R.layout.about_dialog);
    dialog.setTitle(R.string.about_eyekabob_caps);

    ImageView imageView = (ImageView) dialog.findViewById(R.id.aboutDialogImage);
    imageView.setImageResource(R.drawable.ic_launcher);

    String message = context.getResources().getString(R.string.eyekabob_version);
    String versionName = "";
    try {/*www  .ja v a  2 s . c o  m*/
        versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
    } catch (PackageManager.NameNotFoundException e) {
        Log.e(context.getClass().getSimpleName(), e.getMessage());
    }

    message += versionName;
    message += "\n\n" + context.getResources().getString(R.string.about_eyekabob_app);
    message += "\n\n" + context.getResources().getString(R.string.about_last_fm);

    TextView textView = (TextView) dialog.findViewById(R.id.aboutDialogText);
    textView.setText(message);

    dialog.findViewById(R.id.aboutDialogButton).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });

    return dialog;
}

From source file:com.hp.map.CustomerMapActivity.java

public void menuDialog() {
    final Dialog dialog = new Dialog(this);
    LayoutInflater li = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = li.inflate(R.layout.menu_dialog, null, false);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(v);/*from w  w w.jav  a  2  s.com*/

    dialog.setTitle("Danh mc chnh");

    Display display = getWindowManager().getDefaultDisplay();

    dialog.getWindow().setLayout(2 * display.getWidth() / 3, LayoutParams.FILL_PARENT);
    dialog.getWindow().getAttributes().gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;

    lv = (ListView) dialog.findViewById(R.id.menu_list_view);

    lv.setAdapter(
            new DialogArrayAdapter(context, android.R.layout.simple_list_item_1, DetailListData.MENU_LIST));
    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub
            DetailsList selectedValue = (DetailsList) lv.getAdapter().getItem(arg2);
            if (selectedValue.activityClass != null) {
                //if sigout
                if (selectedValue.activityClass == LoginActivity.class) {
                    //LoginActivity.threadLooper.quit();
                }
                startActivity(new Intent(context, selectedValue.activityClass));
            }
        }
    });

    dialog.show();

    //      ImageView iv = (ImageView)dialog.findViewById(R.id.menu_list_view);
    //      iv.setImageResource(1);
}

From source file:com.eeshana.icstories.activities.UploadVideoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // this will copy the license file and the demo video file.
    // to the videokit work folder location.
    // without the license file the library will not work.
    //copyLicenseAndDemoFilesFromAssetsToSDIfNeeded();
    setContentView(R.layout.upload_video_activity);

    height = SignInActivity.getScreenHeight(UploadVideoActivity.this);
    width = SignInActivity.getScreenWidth(UploadVideoActivity.this);
    mProgressDialog = new ProgressDialog(UploadVideoActivity.this);
    pDialog = new ProgressDialog(UploadVideoActivity.this);
    showCustomToast = new ShowCustomToast();
    connectionDetector = new ConnectionDetector(UploadVideoActivity.this);
    //      mProgressDialog=new ProgressDialog(UploadVideoActivity.this,AlertDialog.THEME_HOLO_LIGHT);
    //      mProgressDialog.setFeatureDrawableResource(height,R.drawable.rounded_toast);
    prefs = getSharedPreferences("PREF", MODE_PRIVATE);
    regId = prefs.getString("regid", "NA");
    SharedPreferences pref = getSharedPreferences("DB", 0);
    userid = pref.getString("userid", "1");
    SharedPreferences assign_prefs = getSharedPreferences("ASSIGN", 0);
    assignment_id = assign_prefs.getString("ASSIGN_ID", "");
    videoPath = getIntent().getStringExtra("VIDEOPATH");

    //      iCTextView=(TextView) findViewById(R.id.tvIC);
    //      iCTextView.setTypeface(CaptureVideoActivity.ic_typeface,Typeface.BOLD);
    //      storiesTextView=(TextView) findViewById(R.id.tvStories);
    //      storiesTextView.setTypeface(CaptureVideoActivity.stories_typeface,Typeface.BOLD);
    //      watsStoryTextView=(TextView) findViewById(R.id.tvWhatsStory);
    //      watsStoryTextView.setTypeface(CaptureVideoActivity.stories_typeface,Typeface.ITALIC);

    //      logoImageView=(ImageView) findViewById(R.id.ivLogo);
    //      RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams((int) (width/1.9), (int) (height/9.5));
    //      lp.addRule(RelativeLayout.CENTER_HORIZONTAL);
    //      lp.setMargins(0, 0, 0, 0);
    //      logoImageView.setLayoutParams(lp);

    uploadtTextView = (TextView) findViewById(R.id.tvUpload);
    uploadtTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    //      extension=getIntent().getStringExtra("EXTENSION");
    //      folderPath = Environment.getExternalStorageDirectory().getPath()+"/ICStoriesFolder";
    //      if (!FileUtils.checkIfFolderExists(folderPath)) {
    //         boolean isFolderCreated = FileUtils.createFolder(folderPath);
    //         Log.i(Prefs.TAG, folderPath + " created? " + isFolderCreated);
    //         if (isFolderCreated) {
    ///*from   ww w .  java  2s .  c  om*/
    //         }
    //      }
    //command for rotating video 90 degree
    //String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -vf transpose=1 -s 160x120 -r 30 -aspect 4:3 -ab 48000 -ac 2 -ar 22050 -b 2097k "+folderPath+"/out."+extension;

    //Change Video Resolution:
    //String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -vf transpose=3 -s 320x240 -r 15 -aspect 3:4 -ab 12288 -vcodec mpeg4 -b 2097152 -sample_fmt s16 "+folderPath+"/res."+extension;

    //command for compressing video 
    //      String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -s 320x240 -r 15 -aspect 3:4 -ab 12288 -vcodec mpeg4 -b 2097152 -sample_fmt s16 "+folderPath+"/test."+extension;
    //      setCommand(commandStr);
    //      runTranscoing();

    thumb = ThumbnailUtils.createVideoThumbnail(videoPath, MediaStore.Images.Thumbnails.MINI_KIND);
    System.out.println("THUMB IMG  in uplaod== " + thumb);

    titleEditText = (EditText) findViewById(R.id.etTitle);
    titleEditText.setTypeface(CaptureVideoActivity.stories_typeface);
    descriptionEditText = (EditText) findViewById(R.id.etDescripton);
    descriptionEditText.setTypeface(CaptureVideoActivity.stories_typeface);
    locationEditText = (EditText) findViewById(R.id.etLocation);
    locationEditText.setTypeface(CaptureVideoActivity.stories_typeface);
    isAssignmentButton = (Button) findViewById(R.id.buttonCheck);
    isAssignmentButton.setTypeface(CaptureVideoActivity.stories_typeface);
    isAssignmentButton.setOnClickListener(this);
    dailyAssignTextView = (TextView) findViewById(R.id.tvDailyAssignment);
    dailyAssignTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    uploadButton = (Button) findViewById(R.id.buttonUpload);
    uploadButton.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    RelativeLayout uploadRelativeLayout = (RelativeLayout) findViewById(R.id.rlUpload);
    RelativeLayout.LayoutParams lp9 = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, height / 17);
    lp9.addRule(RelativeLayout.BELOW, R.id.rlDailyAssignment);
    lp9.setMargins(width / 7, 30, width / 7, 0);
    uploadRelativeLayout.setLayoutParams(lp9);
    uploadButton.setOnClickListener(this);

    //bottom bar

    homeRelativeLayout = (RelativeLayout) findViewById(R.id.rlHome);
    homeRelativeLayout.setBackgroundResource(R.drawable.press_border);
    homeRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    homeTextView = (TextView) homeRelativeLayout.findViewById(R.id.tvHome);
    homeTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    homeTextView.setTextColor(Color.parseColor("#fffffe"));
    RelativeLayout.LayoutParams lp4 = new RelativeLayout.LayoutParams(width / 3, width / 5);
    lp4.addRule(RelativeLayout.ALIGN_LEFT);
    homeRelativeLayout.setLayoutParams(lp4);
    homeRelativeLayout.setOnClickListener(this);

    wallRelativeLayout = (RelativeLayout) findViewById(R.id.rlWall);
    wallRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    wallTextView = (TextView) wallRelativeLayout.findViewById(R.id.tvWall);
    wallTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    RelativeLayout.LayoutParams lp5 = new RelativeLayout.LayoutParams(width / 3, width / 5);
    lp5.addRule(RelativeLayout.RIGHT_OF, R.id.rlHome);
    wallRelativeLayout.setLayoutParams(lp5);
    wallRelativeLayout.setOnClickListener(this);

    settingsRelativeLayout = (RelativeLayout) findViewById(R.id.rlSettings);
    settingsRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    settingsTextView = (TextView) settingsRelativeLayout.findViewById(R.id.tvSettings);
    settingsTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    RelativeLayout.LayoutParams lp6 = new RelativeLayout.LayoutParams(width / 3, width / 5);
    lp6.addRule(RelativeLayout.RIGHT_OF, R.id.rlWall);
    settingsRelativeLayout.setLayoutParams(lp6);
    settingsRelativeLayout.setOnClickListener(this);

    // current location
    locationDialog = new Dialog(UploadVideoActivity.this);
    locationDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    locationDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    locationDialog.setContentView(R.layout.location_dialog);
    locationDialog.setCancelable(true);
    LinearLayout dialogLayout = (LinearLayout) locationDialog.findViewById(R.id.ll1);
    okButton = (Button) dialogLayout.findViewById(R.id.OkBtn);
    okButton.setOnClickListener(this);
    cancelButton = (Button) dialogLayout.findViewById(R.id.cancelBtn);
    cancelButton.setOnClickListener(this);

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    boolean network_enabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
    if (network_enabled) {
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
    } else {
        showCustomToast.showToast(UploadVideoActivity.this,
                "Could not find current location. Please enable location services of your device.");
    }
    //      else if(gps_enabled == false){
    //         locationDialog.show();
    //      }
}

From source file:com.gizwits.gizdataaccesssdkdemo.activitys.MainActivity.java

/**
 * ./*from  w ww . j  ava  2  s.  com*/
 * 
 * @return the dialog
 */
public Dialog dateTimePicKDialog() {
    DisplayMetrics dm = new DisplayMetrics();
    dm = this.getResources().getDisplayMetrics();
    int screenWidth = dm.widthPixels;
    int screenHeight = dm.heightPixels;
    LinearLayout dateTimeLayout = (LinearLayout) this.getLayoutInflater().inflate(R.layout.dialog_time, null);

    etLimit = (EditText) dateTimeLayout.findViewById(R.id.etLimit);
    etSkip = (EditText) dateTimeLayout.findViewById(R.id.etSkip);
    etYearStart = (EditText) dateTimeLayout.findViewById(R.id.etYearStart);
    etYearEnd = (EditText) dateTimeLayout.findViewById(R.id.etYearEnd);
    etMonStart = (EditText) dateTimeLayout.findViewById(R.id.etMonStart);
    etMonEnd = (EditText) dateTimeLayout.findViewById(R.id.etMonEnd);
    etDayStart = (EditText) dateTimeLayout.findViewById(R.id.etDayStart);
    etDayEnd = (EditText) dateTimeLayout.findViewById(R.id.etDayEnd);
    etHourStart = (EditText) dateTimeLayout.findViewById(R.id.etHourStart);
    etHourEnd = (EditText) dateTimeLayout.findViewById(R.id.etHourEnd);
    etMinStart = (EditText) dateTimeLayout.findViewById(R.id.etMinStart);
    etMinEnd = (EditText) dateTimeLayout.findViewById(R.id.etMinEnd);
    etSecStart = (EditText) dateTimeLayout.findViewById(R.id.etSecStart);
    etSecEnd = (EditText) dateTimeLayout.findViewById(R.id.etSecEnd);
    btnStartLoad = (Button) dateTimeLayout.findViewById(R.id.btnStartLoad);
    btnStartLoad.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            loadData();

        }
    });

    dialog = new Dialog(this);
    WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
    params.width = (int) (screenWidth * 0.8);
    params.height = screenHeight / 5;
    params.width = (int) (screenWidth * 0.8);
    params.height = (int) (screenHeight * 0.8);
    dialog.getWindow().setAttributes(params);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setContentView(dateTimeLayout);

    return dialog;
}

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//from   w w  w. j a  va 2  s. com
        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();
}

From source file:net.reichholf.dreamdroid.activities.TimerEditActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    final Dialog dialog;

    Calendar cal;/*from  w  w  w. ja  va  2s . co  m*/
    Button buttonApply;

    applyViewValues();

    switch (id) {

    case (DIALOG_PICK_BEGIN_ID):
        cal = getCalendarFromTimestamp(mTimer.getString("begin"));

        dialog = new Dialog(this);
        dialog.setContentView(R.layout.date_time_picker);
        dialog.setTitle(R.string.set_time_begin);

        setDateAndTimePicker(dialog, cal);
        dialogRegisterCancel(dialog);

        buttonApply = (Button) dialog.findViewById(R.id.ButtonApply);
        buttonApply.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                onTimerBeginSet(getCalendarFromPicker(dialog));
            }
        });

        dialog.show();
        break;

    case (DIALOG_PICK_END_ID):
        cal = getCalendarFromTimestamp(mTimer.getString("end"));

        dialog = new Dialog(this);
        dialog.setContentView(R.layout.date_time_picker);
        dialog.setTitle(R.string.set_time_end);

        setDateAndTimePicker(dialog, cal);
        dialogRegisterCancel(dialog);

        buttonApply = (Button) dialog.findViewById(R.id.ButtonApply);
        buttonApply.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                onTimerEndSet(getCalendarFromPicker(dialog));
            }
        });

        dialog.show();
        break;

    case (DIALOG_PICK_REPEATED_ID):
        CharSequence[] days = getResources().getTextArray(R.array.weekdays);
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(getText(R.string.choose_days));
        builder.setMultiChoiceItems(days, mCheckedDays, new OnMultiChoiceClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                mCheckedDays[which] = isChecked;

                String text = setRepeated(mCheckedDays, mTimer);
                mRepeatings.setText(text);

            }

        });
        dialog = builder.create();

        break;

    case (DIALOG_PICK_TAGS_ID):
        CharSequence[] tags = new CharSequence[DreamDroid.TAGS.size()];
        boolean[] selectedTags = new boolean[DreamDroid.TAGS.size()];

        int tc = 0;
        for (String tag : DreamDroid.TAGS) {
            tags[tc] = tag;

            if (mSelectedTags.contains(tag)) {
                selectedTags[tc] = true;
            } else {
                selectedTags[tc] = false;
            }

            tc++;
        }

        mTagsChanged = false;
        mOldTags = new ArrayList<String>();
        mOldTags.addAll(mSelectedTags);

        builder = new AlertDialog.Builder(this);
        builder.setTitle(getText(R.string.choose_tags));

        builder.setMultiChoiceItems(tags, selectedTags, new OnMultiChoiceClickListener() {
            /*
             * (non-Javadoc)
             * 
             * @see android.content.DialogInterface.
             * OnMultiChoiceClickListener
             * #onClick(android.content.DialogInterface, int, boolean)
             */
            @Override
            public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                String tag = DreamDroid.TAGS.get(which);
                mTagsChanged = true;
                if (isChecked) {
                    if (!mSelectedTags.contains(tag)) {
                        mSelectedTags.add(tag);
                    }
                } else {
                    int idx = mSelectedTags.indexOf(tag);
                    if (idx >= 0) {
                        mSelectedTags.remove(idx);
                    }
                }
            }

        });

        builder.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (mTagsChanged) {
                    // TODO Update current Tags
                    String tags = Tag.implodeTags(mSelectedTags);
                    mTimer.put(Timer.TAGS, tags);
                    mTags.setText(tags);
                }
                dialog.dismiss();
                removeDialog(DIALOG_PICK_TAGS_ID);
            }

        });

        builder.setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                mSelectedTags.clear();
                mSelectedTags.addAll(mOldTags);
                dialog.dismiss();
                removeDialog(DIALOG_PICK_TAGS_ID);
            }

        });

        dialog = builder.create();
        break;
    default:
        dialog = null;
    }

    return dialog;
}

From source file:edu.berkeley.boinc.BOINCActivity.java

/**
 * React to selection of nav bar item/*from   w  w w . java  2  s . co  m*/
 * @param item
 * @param position
 * @param init
 */
private void dispatchNavBarOnClick(NavDrawerItem item, boolean init) {
    // update the main content by replacing fragments
    if (item == null) {
        if (Logging.WARNING)
            Log.w(Logging.TAG, "dispatchNavBarOnClick returns, item null.");
        return;
    }
    if (Logging.DEBUG)
        Log.d(Logging.TAG, "dispatchNavBarOnClick for item with id: " + item.getId() + " title: "
                + item.getTitle() + " is project? " + item.isProjectItem());

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    Boolean fragmentChanges = false;
    if (init) {
        // if init, setup status fragment
        ft.replace(R.id.status_container, new StatusFragment());
    }
    if (!item.isProjectItem()) {
        switch (item.getId()) {
        case R.string.tab_tasks:
            ft.replace(R.id.frame_container, new TasksFragment());
            fragmentChanges = true;
            break;
        case R.string.tab_notices:
            ft.replace(R.id.frame_container, new NoticesFragment());
            fragmentChanges = true;
            break;
        case R.string.tab_projects:
            ft.replace(R.id.frame_container, new ProjectsFragment());
            fragmentChanges = true;
            break;
        case R.string.menu_help:
            Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://boinc.berkeley.edu/wiki/BOINC_Help"));
            startActivity(i);
            break;
        case R.string.menu_about:
            final Dialog dialog = new Dialog(this);
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setContentView(R.layout.dialog_about);
            Button returnB = (Button) dialog.findViewById(R.id.returnB);
            TextView tvVersion = (TextView) dialog.findViewById(R.id.version);
            try {
                tvVersion.setText(getString(R.string.about_version) + " "
                        + getPackageManager().getPackageInfo(getPackageName(), 0).versionName);
            } catch (NameNotFoundException e) {
                if (Logging.WARNING)
                    Log.w(Logging.TAG, "version name not found.");
            }

            returnB.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });
            dialog.show();
            break;
        case R.string.menu_eventlog:
            startActivity(new Intent(this, EventLogActivity.class));
            break;
        case R.string.projects_add:
            startActivity(new Intent(this, SelectionListActivity.class));
            break;
        case R.string.tab_preferences:
            ft.replace(R.id.frame_container, new PrefsFragment());
            fragmentChanges = true;
            break;

        default:
            if (Logging.ERROR)
                Log.d(Logging.TAG,
                        "dispatchNavBarOnClick() could not find corresponding fragment for " + item.getTitle());
            break;
        }

    } else {
        // ProjectDetailsFragment. Data shown based on given master URL
        Bundle args = new Bundle();
        args.putString("url", item.getProjectMasterUrl());
        Fragment frag = new ProjectDetailsFragment();
        frag.setArguments(args);
        ft.replace(R.id.frame_container, frag);
        fragmentChanges = true;
    }

    mDrawerLayout.closeDrawer(mDrawerList);

    if (fragmentChanges) {
        ft.commit();
        setTitle(item.getTitle());
        mDrawerListAdapter.selectedMenuId = item.getId(); //highlight item persistently
        mDrawerListAdapter.notifyDataSetChanged(); // force redraw
    }

    if (Logging.DEBUG)
        Log.d(Logging.TAG, "displayFragmentForNavDrawer() " + item.getTitle());
}

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(//from  w w w .ja v a 2  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();

}