android.app.Dialog#requestWindowFeature ( )源码实例Demo

下面列出了android.app.Dialog#requestWindowFeature ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * 确定关机对话框
 * 
 * @param ctx
 * @param contentStr
 *            对话框内容
 * @param r
 *            右按钮监听器
 * @return
 */
public static Dialog getPowerOffDialog(final Activity ctx, OnClickListener r) {
	final Dialog dialog = new Dialog(ctx, R.style.noBackgroundDialog) {
	};
	LayoutInflater layoutInflater = LayoutInflater.from(ctx);
	View v = layoutInflater.inflate(R.layout.dialog_power_off, null);
	Button leftBtn = (Button) v.findViewById(R.id.left_btn);
	Button rightBtn = (Button) v.findViewById(R.id.right_btn);
	leftBtn.setOnClickListener(new View.OnClickListener() {

		@Override
		public void onClick(View arg0) {
			dismissDialog(ctx, dialog);
		}
	});
	rightBtn.setOnClickListener(r);

	dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
	dialog.setCanceledOnTouchOutside(false);
	dialog.setCancelable(false);
	dialog.setContentView(v);
	return dialog;
}
 
源代码2 项目: thunderboard-android   文件: SettingsActivity.java
public void initHelpDialog() {
    helpDialog = new Dialog(this);
    helpDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    helpDialog.setContentView(R.layout.dialog_help_demo_item);
    ((TextView) helpDialog.findViewById(R.id.dialog_help_version_text)).setText(getString(R.string.version_text,
            BuildConfig.VERSION_NAME));
    View okButton = helpDialog.findViewById(R.id.help_ok_button);
    TextView textView = helpDialog.findViewById(R.id.help_text_playstore);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            helpDialog.dismiss();
        }
    });
}
 
源代码3 项目: applivery-android-sdk   文件: UserFeedbackView.java
/**
 * Overrided in order to get fullScreen dialog
 */
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {

    final RelativeLayout root = new RelativeLayout(getActivity());
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    final Dialog dialog = new Dialog(getActivity());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(root);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.YELLOW));
    dialog.getWindow()
            .setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    return dialog;
}
 
private void initCharacteristicWriteDialog() {
    editableFieldsDialog = new Dialog(getActivity());
    editableFieldsDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    editableFieldsDialog.setContentView(R.layout.dialog_characteristic_write);
    editableFieldsDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
    writableFieldsContainer = editableFieldsDialog.findViewById(R.id.characteristic_writable_fields_container);

    int width = (int) (getResources().getDisplayMetrics().widthPixels * 0.9);
    editableFieldsDialog.getWindow().setLayout(width, LinearLayout.LayoutParams.WRAP_CONTENT);

    initWriteModeView(editableFieldsDialog);

    saveValueBtn = editableFieldsDialog.findViewById(R.id.save_btn);
    clearBtn = editableFieldsDialog.findViewById(R.id.clear_btn);
    closeIV = editableFieldsDialog.findViewById(R.id.image_view_close);
}
 
源代码5 项目: iGap-Android   文件: DialogMaker.java
@NonNull
public static DialogMaker makeDialog(Context context) {
    DialogMaker dialogMaker = new DialogMaker();
    dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.gif_dialog);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setCancelable(false);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

    dialog.setOnKeyListener(new Dialog.OnKeyListener() {
        @Override
        public boolean onKey(DialogInterface arg0, int keyCode, KeyEvent event) {
            // TODO Auto-generated method stub
            if (keyCode == KeyEvent.KEYCODE_BACK) {
                dialog.dismiss();
            }
            return true;
        }
    });

    return dialogMaker;
}
 
源代码6 项目: echo   文件: ThemedDialog.java
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().getDecorView().setBackgroundDrawable(null);
    return dialog;
}
 
源代码7 项目: meiShi   文件: DialogBuilder.java
public Dialog create(){
    Dialog dialog=new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    if (dialogView!=null)
        dialog.setContentView(dialogView);
    else if(dialogViewId!=-1)
        dialog.setContentView(dialogViewId);
    return  dialog;
}
 
源代码8 项目: PhotoViewSlider   文件: PhotosViewSlider.java
private void generatePhotoDetail() {
    viewDialog = inflate(getContext(), R.layout.photo_detail, null);
    imgPhoto = (ImageView) viewDialog.findViewById(R.id.img_photo_gallery_detail);
    txtDescriptionGallery = (TextView) viewDialog.findViewById(R.id.txt_photo_gallery_description);
    txtCurrentPosition = (TextView) viewDialog.findViewById(R.id.txt_photo_current_position);
    txtPhotosTotal = (TextView) viewDialog.findViewById(R.id.txt_photo_total);
    btnShare = (ImageButton) viewDialog.findViewById(R.id.btn_share);

    builder = new Dialog(getContext());
    builder.requestWindowFeature(Window.FEATURE_NO_TITLE);
    builder.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
 
源代码9 项目: nubo-test   文件: CustomDialog.java
public CustomDialog(Context context, int type, String title, String message) {

        this.mContext = context;
        this.type = type;
        this.title = title;
        this.message = message;

        dialog = new Dialog(mContext);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        int i = 0;

        dialog.setContentView(R.layout.dialog_custom);
        dialog.setCancelable(false);

        dialog_title = (TextView)dialog.findViewById(R.id.textView_dialog_title);
        dialog_message = (TextView)dialog.findViewById(R.id.textView_dialog_message);
        numberPicker = (NumberPicker)dialog.findViewById(R.id.numberPicker);
        button_dialog_ok=(Button)dialog.findViewById(R.id.button_dialog_ok);
        button_dialog_cancel=(Button)dialog.findViewById(R.id.button_dialog_cancel);
        dialogProgressBar = (ProgressBar)dialog.findViewById(R.id.progressBar);

        editText1 = (EditText)dialog.findViewById(R.id.editText1);
        editText2 = (EditText)dialog.findViewById(R.id.editText2);
        editText3 = (EditText)dialog.findViewById(R.id.editText3);


        if(message.length()==0 || message==null)
            dialog_message.setVisibility(View.GONE);

    }
 
源代码10 项目: Pedometer   文件: Dialog_Statistics.java
public static Dialog getDialog(final Context c, int since_boot) {
	final Dialog d = new Dialog(c);
	d.requestWindowFeature(Window.FEATURE_NO_TITLE);
	d.setContentView(R.layout.statistics);
	d.findViewById(R.id.close).setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			d.dismiss();
		}
	});
	Database db = Database.getInstance(c);

	Pair<Date, Integer> record = db.getRecordData();

	Calendar date = Calendar.getInstance();
	date.setTimeInMillis(Util.getToday());
	int daysThisMonth = date.get(Calendar.DAY_OF_MONTH);

	date.add(Calendar.DATE, -6);

	int thisWeek = db.getSteps(date.getTimeInMillis(), System.currentTimeMillis()) + since_boot;

	date.setTimeInMillis(Util.getToday());
	date.set(Calendar.DAY_OF_MONTH, 1);
	int thisMonth = db.getSteps(date.getTimeInMillis(), System.currentTimeMillis()) + since_boot;

	((TextView) d.findViewById(R.id.record)).setText(
               Fragment_Overview.formatter.format(record.second) + " @ "
			+ java.text.DateFormat.getDateInstance().format(record.first));

	((TextView) d.findViewById(R.id.totalthisweek)).setText(Fragment_Overview.formatter.format(thisWeek));
	((TextView) d.findViewById(R.id.totalthismonth)).setText(Fragment_Overview.formatter.format(thisMonth));

	((TextView) d.findViewById(R.id.averagethisweek)).setText(Fragment_Overview.formatter.format(thisWeek / 7));
	((TextView) d.findViewById(R.id.averagethismonth)).setText(Fragment_Overview.formatter.format(thisMonth / daysThisMonth));
	
	db.close();
	
	return d;
}
 
源代码11 项目: MapsMeasure   文件: Dialogs.java
/**
 * @param m        the Map
 * @param distance the current distance
 * @param area     the current area
 * @return the units dialog
 */
public static Dialog getUnits(final Map m, float distance, double area) {
    final Dialog d = new Dialog(m);
    d.requestWindowFeature(Window.FEATURE_NO_TITLE);
    d.setContentView(R.layout.dialog_unit);
    CheckBox metricCb = (CheckBox) d.findViewById(R.id.metric);
    metricCb.setChecked(Map.metric);
    metricCb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            Map.metric = !Map.metric;
            m.getSharedPreferences("settings", Context.MODE_PRIVATE).edit()
                    .putBoolean("metric", isChecked).commit();
            m.updateValueText();
        }
    });
    ((TextView) d.findViewById(R.id.distance)).setText(
            Map.formatter_two_dec.format(Math.max(0, distance)) + " m\n" +
                    Map.formatter_two_dec.format(distance / 1000) + " km\n\n" +
                    Map.formatter_two_dec.format(Math.max(0, distance / 0.3048f)) + " ft\n" +
                    Map.formatter_two_dec.format(Math.max(0, distance / 0.9144)) + " yd\n" +
                    Map.formatter_two_dec.format(distance / 1609.344f) + " mi\n" +
                    Map.formatter_two_dec.format(distance / 1852f) + " nautical miles");

    ((TextView) d.findViewById(R.id.area)).setText(
            Map.formatter_two_dec.format(Math.max(0, area)) + " m²\n" +
                    Map.formatter_two_dec.format(area / 10000) + " ha\n" +
                    Map.formatter_two_dec.format(area / 1000000) + " km²\n\n" +
                    Map.formatter_two_dec.format(Math.max(0, area / 0.09290304d)) + " ft²\n" +
                    Map.formatter_two_dec.format(area / 4046.8726099d) + " ac (U.S. Survey)\n" +
                    Map.formatter_two_dec.format(area / 2589988.110336d) + " mi²");
    d.findViewById(R.id.close).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            d.dismiss();
        }
    });
    return d;
}
 
/**
 * Gets the no network dialog.
 * 
 * @param ctx
 *            the ctx
 * @return the no network dialog
 */
public static Dialog getNoNetworkDialog(Context ctx) {
	Dialog dialog = new Dialog(ctx, R.style.noBackgroundDialog);
	LayoutInflater layoutInflater = LayoutInflater.from(ctx);
	View contentView = layoutInflater.inflate(R.layout.dialog_no_network,
			null);
	dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
	dialog.setContentView(contentView);
	return dialog;
}
 
源代码13 项目: AndroidChromium   文件: ItemChooserDialog.java
private void showDialogForView(View view) {
    mDialog = new Dialog(mActivity) {
        @Override
        public void onWindowFocusChanged(boolean hasFocus) {
            super.onWindowFocusChanged(hasFocus);
            if (!hasFocus) super.dismiss();
        }
    };
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mDialog.setCanceledOnTouchOutside(true);
    mDialog.addContentView(view,
            new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                                          LinearLayout.LayoutParams.MATCH_PARENT));
    mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            mItemSelectedCallback.onItemSelected("");
        }
    });

    Window window = mDialog.getWindow();
    if (!DeviceFormFactor.isTablet(mActivity)) {
        // On smaller screens, make the dialog fill the width of the screen,
        // and appear at the top.
        window.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
        window.setGravity(Gravity.TOP);
        window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
                         ViewGroup.LayoutParams.WRAP_CONTENT);
    }

    mDialog.show();
}
 
/**
 * INITIALIZES ABOUT DIALOG
 *******************************************************/
private void initAboutDialog() {
    dialogLicense = new Dialog(this);
    dialogLicense.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialogLicense.setContentView(R.layout.dialog_about_silicon_labs_blue_gecko);
    WebView webView = dialogLicense.findViewById(R.id.menu_item_license);
    Button closeButton = dialogLicense.findViewById(R.id.close_about_btn);
    webView.loadUrl(ABOUT_DIALOG_HTML_ASSET_FILE_PATH);
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialogLicense.dismiss();
        }
    });
}
 
源代码15 项目: letv   文件: DialogFragment.java
public void setupDialog(Dialog dialog, int style) {
    switch (style) {
        case 1:
        case 2:
            break;
        case 3:
            dialog.getWindow().addFlags(24);
            break;
        default:
            return;
    }
    dialog.requestWindowFeature(1);
}
 
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.requestWindowFeature(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return dialog;
}
 
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    initBuilderArguments();

    Dialog dialog = new Dialog(getActivity(), getTheme()) {
        @Override
        public void onBackPressed() {
            onDiscardButtonClick();
        }
    };
    if (!fullScreen)
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    return dialog;
}
 
源代码18 项目: date_picker_converter   文件: TimePickerDialog.java
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    return dialog;
}
 
源代码19 项目: GravityBox   文件: QuickAppTile.java
@Override
public boolean handleLongClick() {
    LayoutInflater inflater = LayoutInflater.from(mGbContext);
    View appv = inflater.inflate(R.layout.quick_settings_app_dialog, null);
    int count = 0;
    AppInfo lastAppInfo = null;
    for (AppInfo ai : mAppSlots) {
        TextView tv = (TextView) appv.findViewById(ai.getResId());
        if (ai.getValue() == null) {
            tv.setVisibility(View.GONE);
            continue;
        }

        tv.setText(ai.getAppName());
        tv.setTextSize(1, 10);
        tv.setMaxLines(2);
        tv.setEllipsize(TruncateAt.END);
        tv.setCompoundDrawablesWithIntrinsicBounds(null, ai.getAppIcon(), null, null);
        tv.setClickable(true);
        tv.setOnClickListener(mOnSlotClick);
        count++;
        lastAppInfo = ai;
    }

    if (count == 1) {
        try {
            startActivity(lastAppInfo.getIntent());
        } catch (Throwable t) {
            log(getKey() + ": Unable to start activity: " + t.getMessage());
        }
    } else if (count > 1) {
        mDialog = new Dialog(mContext, android.R.style.Theme_Material_Dialog_NoActionBar);
        mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        mDialog.setContentView(appv);
        mDialog.setCanceledOnTouchOutside(true);
        mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL);
        int pf = XposedHelpers.getIntField(mDialog.getWindow().getAttributes(), "privateFlags");
        pf |= 0x00000010;
        XposedHelpers.setIntField(mDialog.getWindow().getAttributes(), "privateFlags", pf);
        mDialog.getWindow().clearFlags(LayoutParams.FLAG_DIM_BEHIND);
        mDialog.show();
        mHandler.removeCallbacks(mDismissDialogRunnable);
        mHandler.postDelayed(mDismissDialogRunnable, 4000);
    }
    return true;
}
 
源代码20 项目: aptoide-client-v8   文件: RemoteInstallDialog.java
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) {
  Dialog dialog = super.onCreateDialog(savedInstanceState);
  dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
  return dialog;
}