Java Code Examples for android.support.v7.app.AlertDialog#setView()
The following examples show how to use
android.support.v7.app.AlertDialog#setView() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RobocarConnectionDialog.java From robocar with Apache License 2.0 | 6 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog dialog = new AlertDialog.Builder(getContext()) .setTitle(R.string.dialog_title_connect_to_robocar) .create(); // Inflate the content separately so that we can use findViewById() @SuppressLint("InflateParams") View view = dialog.getLayoutInflater().inflate(R.layout.fragment_auth_dialog, null, false); dialog.setView(view); dialog.setCanceledOnTouchOutside(false); // can still cancel with Back mMessageText = view.findViewById(android.R.id.message); mPositiveButton = view.findViewById(R.id.positive_button); mNegativeButton = view.findViewById(R.id.negative_button); mProgressContainer = view.findViewById(R.id.progress_container); mProgressText = view.findViewById(R.id.progress_text); mPositiveButton.setOnClickListener(this); mNegativeButton.setOnClickListener(this); return dialog; }
Example 2
Source File: MainActivity.java From DragScaleCircleView with Apache License 2.0 | 5 votes |
private void showDialog(final Drawable drawable) { AlertDialog.Builder builder = new AlertDialog.Builder(this); final AlertDialog dialog = builder.create(); LayoutInflater inflater = getLayoutInflater(); View dialogLayout = inflater.inflate(R.layout.image_dialog, null); ImageView image = (ImageView) dialogLayout.findViewById(R.id.imageDialog); image.setImageDrawable(drawable); dialog.setView(dialogLayout); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.getWindow().setWindowAnimations(R.style.DialogTheme); dialog.show(); }
Example 3
Source File: UpdateAgent.java From update with Apache License 2.0 | 4 votes |
@Override public void prompt(IUpdateAgent agent) { if (mContext instanceof Activity && ((Activity) mContext).isFinishing()) { return; } final UpdateInfo info = agent.getInfo(); String size = Formatter.formatShortFileSize(mContext, info.size); String content = String.format("最新版本:%1$s\n新版本大小:%2$s\n\n更新内容\n%3$s", info.versionName, size, info.updateContent); final AlertDialog dialog = new AlertDialog.Builder(mContext).create(); dialog.setTitle("应用更新"); dialog.setCancelable(false); dialog.setCanceledOnTouchOutside(false); float density = mContext.getResources().getDisplayMetrics().density; TextView tv = new TextView(mContext); tv.setMovementMethod(new ScrollingMovementMethod()); tv.setVerticalScrollBarEnabled(true); tv.setTextSize(14); tv.setMaxHeight((int) (250 * density)); dialog.setView(tv, (int) (25 * density), (int) (15 * density), (int) (25 * density), 0); DialogInterface.OnClickListener listener = new DefaultPromptClickListener(agent, true); if (info.isForce) { tv.setText("您需要更新应用才能继续使用\n\n" + content); dialog.setButton(DialogInterface.BUTTON_POSITIVE, "确定", listener); } else { tv.setText(content); dialog.setButton(DialogInterface.BUTTON_POSITIVE, "立即更新", listener); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "以后再说", listener); if (info.isIgnorable) { dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "忽略该版", listener); } } dialog.show(); }