本文整理匯總了Java中android.app.AlertDialog.getWindow方法的典型用法代碼示例。如果您正苦於以下問題:Java AlertDialog.getWindow方法的具體用法?Java AlertDialog.getWindow怎麽用?Java AlertDialog.getWindow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.app.AlertDialog
的用法示例。
在下文中一共展示了AlertDialog.getWindow方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showOptionDialog
import android.app.AlertDialog; //導入方法依賴的package包/類
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();
}
示例2: buildBottomDialog
import android.app.AlertDialog; //導入方法依賴的package包/類
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;
}
示例3: onCreate
import android.app.AlertDialog; //導入方法依賴的package包/類
@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();
}
});
}
示例4: onCreate
import android.app.AlertDialog; //導入方法依賴的package包/類
@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();
}
});
}
示例5: alterDialog
import android.app.AlertDialog; //導入方法依賴的package包/類
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;
}
示例6: showDialogEdit
import android.app.AlertDialog; //導入方法依賴的package包/類
/**
* 顯示輸入框
*/
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();
}
});
}
示例7: showDialogEdit
import android.app.AlertDialog; //導入方法依賴的package包/類
/**
* 顯示輸入框
*/
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();
}
});
}
示例8: showDialogEdit
import android.app.AlertDialog; //導入方法依賴的package包/類
/**
* 顯示輸入框
*/
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();
}
});
}