本文整理匯總了Java中android.support.v7.app.AlertDialog.Builder方法的典型用法代碼示例。如果您正苦於以下問題:Java AlertDialog.Builder方法的具體用法?Java AlertDialog.Builder怎麽用?Java AlertDialog.Builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.app.AlertDialog
的用法示例。
在下文中一共展示了AlertDialog.Builder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildMdLoading
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
protected BuildBean buildMdLoading(BuildBean bean) {
AlertDialog.Builder builder = new AlertDialog.Builder(bean.mContext);
View root;
if (bean.isVertical) {
root = View.inflate(bean.mContext, R.layout.dialogui_loading_vertical, null);
} else {
root = View.inflate(bean.mContext, R.layout.dialogui_loading_horizontal, null);
}
View llBg = (View) root.findViewById(R.id.dialogui_ll_bg);
ProgressBar pbBg = (ProgressBar) root.findViewById(R.id.pb_bg);
TextView tvMsg = (TextView) root.findViewById(R.id.dialogui_tv_msg);
tvMsg.setText(bean.msg);
if (bean.isWhiteBg) {
llBg.setBackgroundResource(R.drawable.dialogui_shape_wihte_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_rotate_mum));
tvMsg.setTextColor(bean.mContext.getResources().getColor(R.color.text_black));
} else {
llBg.setBackgroundResource(R.drawable.dialogui_shape_gray_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_rotate_mum_light));
tvMsg.setTextColor(Color.WHITE);
}
builder.setView(root);
AlertDialog dialog = builder.create();
bean.alertDialog = dialog;
return bean;
}
示例2: actualizar
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
private void actualizar() {
PAGINA = 1;
statuses.clear();
adapter.notifyDataSetChanged();
adapter = null;
try {
tvEmptyTweets.setVisibility(View.GONE);
Paging page = new Paging(PAGINA, 10);
statuses.addAll(TWITTER.getUserTimeline(USER, page));
PAGINA++;
} catch (TwitterException exception) {
AlertDialog.Builder mensajeError = new AlertDialog.Builder(getContext());
mensajeError.create();
mensajeError.setMessage("Necesitas estar conectado para poder ver los ultimos tweets");
mensajeError.show();
tvEmptyTweets.setVisibility(View.VISIBLE);
}
adapter = new RVTweetAdapter(getActivity(), statuses);
rvTweets.setAdapter(adapter);
swipeRefreshLayoutTwitter.setRefreshing(false);
}
示例3: confirmation_dialogbox
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
public void confirmation_dialogbox(final DatabaseReference databaseReference1, final String new_subject)
{
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which){
case DialogInterface.BUTTON_POSITIVE:
databaseReference1.push().setValue(new_subject);
//Yes button clicked
break;
case DialogInterface.BUTTON_NEGATIVE:
//No button clicked
break;
}
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage("Are you sure want to create new subject with name "+new_subject+" ?").setPositiveButton("Yes", dialogClickListener)
.setNegativeButton("No", dialogClickListener).show();
}
示例4: showDetailDialog
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
private void showDetailDialog(Face face) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("人臉分析詳情");
ScrollView scrollView = new ScrollView(this);
TextView textView = new TextView(this);
textView.setTextColor(Color.BLACK);
textView.setText(face.toString());
scrollView.addView(textView);
//builder.setMessage(face.toString());
builder.setView(scrollView);
builder.setCancelable(true);
builder.setPositiveButton("確定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
dialog = builder.show();
WindowManager.LayoutParams layoutParams = dialog.getWindow().getAttributes();
layoutParams.alpha = 0.6f;
dialog.getWindow().setAttributes(layoutParams);
}
示例5: onCreateDialog
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
@SuppressLint("InflateParams")
@Override
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
View dialogView = LayoutInflater.from(getActivity())
.inflate(R.layout.dialog_message, null);
TextView messageView = (TextView) dialogView.findViewById(R.id.message);
messageView.setMovementMethod(LinkMovementMethod.getInstance());
messageView.setText(Html.fromHtml(getArguments().getString(ARG_MESSAGE)));
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppTheme_AlertDialog);
builder.setTitle(getArguments().getString(ARG_TITLE))
.setIcon(getArguments().getInt(ARG_ICON))
.setView(dialogView)
.setPositiveButton(R.string.OK, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return builder.create();
}
示例6: onCreateDialog
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
Bundle bundle = getArguments();
this.layoutId = bundle.getInt(LAYOUT_KEY);
LayoutInflater inflater = getActivity().getLayoutInflater();
View v = inflater.inflate(layoutId, null);
RelativeLayout title = (RelativeLayout) v.findViewById(R.id.titleDialog);
if (bundle.containsKey(COLOR_KEY)) {
this.backgroundTitleColor = bundle.getInt(COLOR_KEY);
title.setBackgroundColor(backgroundTitleColor);
}
// View title = inflater.inflate(R.layout.dialog_openinghours_title,null);
builder.setView(v);
builder.setPositiveButton(R.string.dialog_ok_button, null);
// builder.setCustomTitle(title);
builder.setIcon(R.drawable.clock);
// builder.setMessage(R.string.dialog_mensaje);
return builder.create();
}
示例7: initAction
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
private void initAction() {
View dialogView = LayoutInflater.from(this).inflate(R.layout.d_clip, null);
rcvDialogApps = (RecyclerView) dialogView.findViewById(R.id.rcv_dialog_clip);
rcvDialogApps.setLayoutManager(new LinearLayoutManager(this));
rcvDialogApps.setHasFixedSize(true);
DialogClipAdapter adapter = new DialogClipAdapter(clipData);
rcvDialogApps.setAdapter(adapter);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getResources().getString(R.string.clipboard))
.setView(dialogView)
.setNegativeButton(R.string.no,null)
.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
Log.i(TAG, "onDismiss: ");
finish();
}
}).create().show();
}
示例8: calibrate
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
public void calibrate(View view) {
// Show calibration screen
EditText editText2 = (EditText)findViewById(R.id.editText2);
EditText editText3 = (EditText)findViewById(R.id.editText3);
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = sharedPreferences.edit();
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
try {
if (!editText2.getText().toString().isEmpty() && !editText3.getText().toString().isEmpty()) {
// Save valuesget vid
calibrationWidth = Double.parseDouble(editText2.getText().toString());
calibrationDistance = Double.parseDouble(editText3.getText().toString());
editor.putLong(getString(R.string.calibration_distance_key), Double.doubleToLongBits(calibrationDistance));
editor.putLong(getString(R.string.calibration_width_key), Double.doubleToLongBits(calibrationWidth));
editor.apply();
alertDialogBuilder.setMessage(getString(R.string.text_calibrationsuccess))
.setCancelable(false)
.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
})
.show();
} else {
alertDialogBuilder.setMessage(R.string.text_notCalibrated)
.show();
}
} catch (NullPointerException e) {
e.printStackTrace();
alertDialogBuilder.setMessage(R.string.text_notCalibrated)
.show();
}
}
示例9: showDeleteDialog
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
private void showDeleteDialog(final String text, final int position) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.download_delete_title);
builder.setPositiveButton(R.string.delete_positive, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
// historyHelper.remove(text);
adapter.notifyItemRemoved(position);
}
});
builder.create().show();
}
示例10: deleteFile
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
/**
* 메인 리스트에서 파일을 제거하는 메소드
* @param _index 제거할 파일의 인덱스
*/
private void deleteFile(final int _index) {
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle(R.string.file_dialog_title_delete);
dialog.setMessage(R.string.file_dialog_message_question_delete);
DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface _dialog, int _which) {
if (_which == AlertDialog.BUTTON_POSITIVE) {
File file = new File(mCurFolderFileList.get(_index).mFilePath);
if (file.exists()) {
if (file.delete()) {
Snackbar.make(mContextView, R.string.file_dialog_toast_delete, Snackbar.LENGTH_SHORT).show();
mCurFolderFileList.remove(_index);
mCurFolderGridView.removeViewAt(_index);
mCurFileAdapter.notifyItemRemoved(_index);
mCurFileAdapter.notifyItemRangeChanged(_index, mCurFolderFileList.size());
mCurFileAdapter.notifyDataSetChanged();
} else {
Snackbar.make(mContextView, R.string.error_folder_not_exist, Snackbar.LENGTH_SHORT).show();
}
}
}
_dialog.dismiss();
}
};
dialog.setNegativeButton(R.string.folder_dialog_button_cancel, clickListener);
dialog.setPositiveButton(R.string.folder_dialog_button_delete, clickListener);
dialog.show();
}
示例11: onDetailItemLongClick
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
@Override
public boolean onDetailItemLongClick(final int adapterPosition) {
//TODO: generalize the DetailView to include this code also
// such that it is not duplicated between MainActivity and HistoryRecyclerViewAdapter
AlertDialog.Builder builder = new AlertDialog.Builder(mContext)
.setTitle(R.string.dlg_delete_image_title)
.setMessage(R.string.dlg_delete_image_text)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
ContentValues values = new ContentValues();
values.put(ActivityDiaryContract.DiaryImage._DELETED, 1);
mContext.mQHandler.startUpdate(0,
null,
ActivityDiaryContract.DiaryImage.CONTENT_URI,
values,
ActivityDiaryContract.DiaryImage._ID + "=?",
new String[]{Long.toString(
mViewHolders.get(adapterPosition).mDetailAdapter.getDiaryImageIdAt(adapterPosition))}
);
}})
.setNegativeButton(android.R.string.no, null);
builder.create().show();
return true;
}
示例12: getConfirmDialog
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
/**
* 獲取一個驗證對話框,沒有點擊事件,取消、確定
*/
public static AlertDialog.Builder getConfirmDialog(
Context context,
String title,
String message) {
return getConfirmDialog(context, title, message, "確定", "取消", false, null, null);
}
示例13: selectImage
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
private void selectImage() {
final String[] items = {"Take Photo", /*"Choose from Library",*/ "Cancel"};
try {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Add Photo!");
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
boolean result = EyeRS.checkPermission(NewItemActivity.this);
if (items[item].equals("Take Photo")) {
userChoosenTask = "Take Photo";
if (result) {
cameraIntent();
}
}
// else if (items[item].equals("Choose from Library")) {
// userChoosenTask = "Choose from Library";
// if (result)
// galleryIntent();
//
// }
else if (items[item].equals("Cancel")) {
dialog.dismiss();
}
}
});
builder.show();
} catch (Exception ex) {
Log.e("selectImage()", ex.getMessage(), ex);
}
}
示例14: showWarningDialog
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
public void showWarningDialog(String message) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(message);
builder.setPositiveButton(R.string.button_ok, null);
builder.show();
}
示例15: showMediaInfo
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
public void showMediaInfo() {
if (mMediaPlayer == null)
return;
int selectedVideoTrack = MediaPlayerCompat.getSelectedTrack(mMediaPlayer, ITrackInfo.MEDIA_TRACK_TYPE_VIDEO);
int selectedAudioTrack = MediaPlayerCompat.getSelectedTrack(mMediaPlayer, ITrackInfo.MEDIA_TRACK_TYPE_AUDIO);
int selectedSubtitleTrack = MediaPlayerCompat.getSelectedTrack(mMediaPlayer, ITrackInfo.MEDIA_TRACK_TYPE_TIMEDTEXT);
TableLayoutBinder builder = new TableLayoutBinder(getContext());
builder.appendSection(R.string.mi_player);
builder.appendRow2(R.string.mi_player, MediaPlayerCompat.getName(mMediaPlayer));
builder.appendSection(R.string.mi_media);
builder.appendRow2(R.string.mi_resolution, buildResolution(mVideoWidth, mVideoHeight, mVideoSarNum, mVideoSarDen));
builder.appendRow2(R.string.mi_length, buildTimeMilli(mMediaPlayer.getDuration()));
ITrackInfo trackInfos[] = mMediaPlayer.getTrackInfo();
if (trackInfos != null) {
int index = -1;
for (ITrackInfo trackInfo : trackInfos) {
index++;
int trackType = trackInfo.getTrackType();
if (index == selectedVideoTrack) {
builder.appendSection(getContext().getString(R.string.mi_stream_fmt1, index) + " " + getContext().getString(R.string.mi__selected_video_track));
} else if (index == selectedAudioTrack) {
builder.appendSection(getContext().getString(R.string.mi_stream_fmt1, index) + " " + getContext().getString(R.string.mi__selected_audio_track));
} else if (index == selectedSubtitleTrack) {
builder.appendSection(getContext().getString(R.string.mi_stream_fmt1, index) + " " + getContext().getString(R.string.mi__selected_subtitle_track));
} else {
builder.appendSection(getContext().getString(R.string.mi_stream_fmt1, index));
}
builder.appendRow2(R.string.mi_type, buildTrackType(trackType));
builder.appendRow2(R.string.mi_language, buildLanguage(trackInfo.getLanguage()));
IMediaFormat mediaFormat = trackInfo.getFormat();
if (mediaFormat == null) {
} else if (mediaFormat instanceof IjkMediaFormat) {
switch (trackType) {
case ITrackInfo.MEDIA_TRACK_TYPE_VIDEO:
builder.appendRow2(R.string.mi_codec, mediaFormat.getString(IjkMediaFormat.KEY_IJK_CODEC_LONG_NAME_UI));
builder.appendRow2(R.string.mi_profile_level, mediaFormat.getString(IjkMediaFormat.KEY_IJK_CODEC_PROFILE_LEVEL_UI));
builder.appendRow2(R.string.mi_pixel_format, mediaFormat.getString(IjkMediaFormat.KEY_IJK_CODEC_PIXEL_FORMAT_UI));
builder.appendRow2(R.string.mi_resolution, mediaFormat.getString(IjkMediaFormat.KEY_IJK_RESOLUTION_UI));
builder.appendRow2(R.string.mi_frame_rate, mediaFormat.getString(IjkMediaFormat.KEY_IJK_FRAME_RATE_UI));
builder.appendRow2(R.string.mi_bit_rate, mediaFormat.getString(IjkMediaFormat.KEY_IJK_BIT_RATE_UI));
break;
case ITrackInfo.MEDIA_TRACK_TYPE_AUDIO:
builder.appendRow2(R.string.mi_codec, mediaFormat.getString(IjkMediaFormat.KEY_IJK_CODEC_LONG_NAME_UI));
builder.appendRow2(R.string.mi_profile_level, mediaFormat.getString(IjkMediaFormat.KEY_IJK_CODEC_PROFILE_LEVEL_UI));
builder.appendRow2(R.string.mi_sample_rate, mediaFormat.getString(IjkMediaFormat.KEY_IJK_SAMPLE_RATE_UI));
builder.appendRow2(R.string.mi_channels, mediaFormat.getString(IjkMediaFormat.KEY_IJK_CHANNEL_UI));
builder.appendRow2(R.string.mi_bit_rate, mediaFormat.getString(IjkMediaFormat.KEY_IJK_BIT_RATE_UI));
break;
default:
break;
}
}
}
}
AlertDialog.Builder adBuilder = builder.buildAlertDialogBuilder();
adBuilder.setTitle(R.string.media_information);
adBuilder.setNegativeButton(R.string.close, null);
adBuilder.show();
}