Java Code Examples for android.app.AlertDialog.getWindow()

The following are Jave code examples for showing how to use getWindow() of the android.app.AlertDialog class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: AOSP-Kayboard-7.1.2   File: LatinIME.java   Source Code and License Vote up 7 votes
private void showOptionDialog(final AlertDialog dialog) {
    final IBinder windowToken = mKeyboardSwitcher.getMainKeyboardView().getWindowToken();
    if (windowToken == null) {
        return;
    }

    final Window window = dialog.getWindow();
    final WindowManager.LayoutParams lp = window.getAttributes();
    lp.token = windowToken;
    lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
    window.setAttributes(lp);
    window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

    mOptionsDialog = dialog;
    dialog.show();
}
 
Example 2
Project: simple-keyboard   File: LatinIME.java   Source Code and License Vote up 6 votes
private void showOptionDialog(final AlertDialog dialog) {
    final IBinder windowToken = mKeyboardSwitcher.getMainKeyboardView().getWindowToken();
    if (windowToken == null) {
        return;
    }

    final Window window = dialog.getWindow();
    final WindowManager.LayoutParams lp = window.getAttributes();
    lp.token = windowToken;
    lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
    window.setAttributes(lp);
    window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

    mOptionsDialog = dialog;
    dialog.show();
}
 
Example 3
Project: letv   File: DialogUtils.java   Source Code and License Vote up 5 votes
public static AlertDialog buildBottomDialog(Activity activity, View contentView) {
    AlertDialog dialog = new Builder(activity).create();
    dialog.setCanceledOnTouchOutside(true);
    dialog.show();
    dialog.setContentView(contentView);
    Window dialogWindow = dialog.getWindow();
    Display d = activity.getWindowManager().getDefaultDisplay();
    LayoutParams p = dialogWindow.getAttributes();
    p.width = d.getWidth();
    dialogWindow.setAttributes(p);
    dialogWindow.setGravity(80);
    return dialog;
}
 
Example 4
Project: DoList   File: ClockActivity.java   Source Code and License Vote up 5 votes
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_clock);

	Intent intent = getIntent();
	// ��ȡ�������
	String contentValue = intent.getStringExtra("content");
	String alarmValue = intent.getStringExtra("alarmtime");

	mp = MediaPlayer.create(ClockActivity.this, R.raw.alarm);// ����mediaplayer����
	mp.start();// ��ʼ����

	AlertDialog alertDialog = new AlertDialog.Builder(ClockActivity.this)
			.create();
	alertDialog.setCancelable(false); // ���öԻ�������ĵط��ͷ��ؼ�.
	alertDialog.show();
	Window window = alertDialog.getWindow();// �Զ���AlertDialog��ʽ
	window.setContentView(R.layout.clock);
	TextView tv_time = (TextView) window.findViewById(R.id.clocktime); // ��ʾʱ��
	tv_time.setText(alarmValue);
	TextView tv_message = (TextView) window.findViewById(R.id.clockcontent); // ��ʾ����
	tv_message.setText(contentValue);
	Button clockbutton = (Button) window.findViewById(R.id.btn_clock);// ȡ�����Ӱ�ť
	clockbutton.setOnClickListener(new OnClickListener() {

		@Override
		public void onClick(View v) {
			mp.stop();
			mp.reset();
			ClockActivity.this.finish();
		}
	});
}
 
Example 5
Project: DoList   File: FestivalClockActivity.java   Source Code and License Vote up 5 votes
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_clock);

	Intent intent = getIntent();
	// 获取相关数据
	String contentValue = intent.getStringExtra("content");
	String alarmValue = intent.getStringExtra("alarmtime");

	mp = MediaPlayer.create(FestivalClockActivity.this, R.raw.alarm);// 创建mediaplayer对象
	mp.start();

	String Message = alarmValue + "\n" + contentValue; // 传入节日

	AlertDialog alertDialog = new AlertDialog.Builder(
			FestivalClockActivity.this).create();
	alertDialog.setCancelable(false); // 禁用对话框以外的地方和返回键.
	alertDialog.show();
	Window window = alertDialog.getWindow();// 自定义AlertDialog样式
	window.setContentView(R.layout.clock);
	TextView tv_time = (TextView) window.findViewById(R.id.clocktime); // 显示时间
	tv_time.setText(alarmValue);
	TextView tv_message = (TextView) window.findViewById(R.id.clockcontent); // 显示内容
	tv_message.setText(contentValue);
	Button clockbutton = (Button) window.findViewById(R.id.btn_clock);// 取消闹钟按钮
	clockbutton.setOnClickListener(new OnClickListener() {

		@Override
		public void onClick(View v) {
			mp.stop();
			mp.reset();
			FestivalClockActivity.this.finish();
		}
	});
}
 
Example 6
Project: JKApp   File: Util.java   Source Code and License Vote up 5 votes
public static AlertDialog alterDialog(Context context,View view){
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setView(view);
    AlertDialog dialog = builder.show();
    dialog.setCancelable(false);
    Window window=dialog.getWindow();
    window.setGravity(Gravity.CENTER);
    window.setWindowAnimations(R.style.popwinAnim);
    return dialog;
}
 
Example 7
Project: GCSApp   File: SettingActivity.java   Source Code and License Vote up 5 votes
/**
 * 显示输入框
 */
public void showDialogEdit(Context context) {
    final AlertDialog dialog;
    AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.DialogTransBackGround);
    dialog = builder.create();
    dialog.setCancelable(true);
    dialog.show();
    Window window = dialog.getWindow();
    window.setWindowAnimations(R.style.AnimBottom);
    window.clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
    View view_dialog = LayoutInflater.from(context).inflate(R.layout.create_tip_dialog_layout, null);
    dialog.setContentView(view_dialog);
    ((TextView)view_dialog.findViewById(R.id.edt_create_layout_input)).setText("退出当前账号?");

    TextView bt_yes = (TextView) view_dialog.findViewById(R.id.set);
    TextView bt_no = (TextView) view_dialog.findViewById(R.id.cancel);

    bt_yes.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            logout();
            dialog.dismiss();
        }
    });
    bt_no.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });
}
 
Example 8
Project: GCSApp   File: MainActivity.java   Source Code and License Vote up 5 votes
/**
     * 显示输入框
     */
    public void showDialogEdit(Context context) {
        final AlertDialog dialog;
        AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.DialogTransBackGround);
        dialog = builder.create();
        dialog.setCancelable(true);
        dialog.show();
        Window window = dialog.getWindow();
        window.setWindowAnimations(R.style.AnimBottom);
        window.clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        View view_dialog = LayoutInflater.from(context).inflate(R.layout.create_tip_dialog_layout, null);
        ((TextView) view_dialog.findViewById(R.id.edt_create_layout_input)).setText("退出app?");
        dialog.setContentView(view_dialog);

        TextView bt_yes = (TextView) view_dialog.findViewById(R.id.set);
        TextView bt_no = (TextView) view_dialog.findViewById(R.id.cancel);

        bt_yes.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                logout();
                dialog.dismiss();
                ActivityManagerUtil.getInstance().finishAllActivity();

            }
        });
        bt_no.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
            }
        });
    }
 
Example 9
Project: GCSApp   File: DialogUtils.java   Source Code and License Vote up 5 votes
/**
 * 显示输入框
 */
public static void showDialogEdit(Context context, final TextView textView) {
    final AlertDialog dialog;
    AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.DialogTransBackGround);
    dialog = builder.create();
    dialog.setCancelable(true);
    dialog.show();
    Window window = dialog.getWindow();
    window.setWindowAnimations(R.style.AnimBottom);
    window.clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
    View view_dialog = LayoutInflater.from(context).inflate(R.layout.create_ac_input_layout, null);
    dialog.setContentView(view_dialog);

    final EditText et_content = (EditText) view_dialog.findViewById(R.id.edt_create_layout_input);
    TextView bt_yes = (TextView) view_dialog.findViewById(R.id.set);
    TextView bt_no = (TextView) view_dialog.findViewById(R.id.cancel);

    bt_yes.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String content = et_content.getText().toString().trim();
            AppUtils.hintKbTwo(et_content);
            if (!content.isEmpty()) {
                textView.setText(content);
                dialog.dismiss();
            }
        }
    });
    bt_no.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            AppUtils.hintKbTwo(et_content);
            dialog.dismiss();
        }
    });
}
 
Example 10
Project: LeCatApp   File: Util.java   Source Code and License Vote up 5 votes
public static AlertDialog alterDialog(Context context,View view){
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setView(view);
    AlertDialog dialog = builder.show();
    dialog.setCancelable(false);
    Window window=dialog.getWindow();
    window.setGravity(Gravity.CENTER);
    window.setWindowAnimations(R.style.popwinAnim);
    return dialog;
}