本文整理汇总了Java中android.support.v7.app.AlertDialog.Builder.setTitle方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.setTitle方法的具体用法?Java Builder.setTitle怎么用?Java Builder.setTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.app.AlertDialog.Builder
的用法示例。
在下文中一共展示了Builder.setTitle方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeDialogDisplay
import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
/**
* Methods that computes and displays the dialog content.
*
* @param isForAnnouncement boolean
*/
private final void computeDialogDisplay(boolean isForAnnouncement)
{
final Builder builder = new Builder(getContext());
builder.setTitle(R.string.out_of_app_push_notifications_dialog_title);
final View dialogContainerView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_out_of_app_push_notifications, (ViewGroup) getView().getParent(), false);
iconTitleMessageButton = dialogContainerView.findViewById(R.id.iconTitleMessageButton);
iconTitleMessageBigTextButton = dialogContainerView.findViewById(R.id.iconTitleMessageBigTextButton);
iconTitleMessageBigImageButton = dialogContainerView.findViewById(R.id.iconTitleMessageBigImageButton);
this.isForAnnouncement = isForAnnouncement;
iconTitleMessageButton.setOnClickListener(this);
iconTitleMessageBigTextButton.setOnClickListener(this);
iconTitleMessageBigImageButton.setOnClickListener(this);
builder.setView(dialogContainerView);
this.alertDialog = builder.create();
this.alertDialog.show();
AzmeTracker.sendEvent(getActivity(), isForAnnouncement ? "display_out_of_app_announcement" : "display_out_of_app_notification_only");
}
开发者ID:Azure,项目名称:azure-mobile-engagement-app-android,代码行数:26,代码来源:OutOfAppPushNotificationsFragment.java
示例2: showAlertDialog
import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
/**
* Shows message in an AlertDialog.
*
* @param message contains identify results processed into a string.
*/
private void showAlertDialog(StringBuilder message) {
Builder alertDialogBuilder = new Builder(this);
// set title
alertDialogBuilder.setTitle("Number of elements found");
// set dialog message
alertDialogBuilder
.setMessage(message)
.setCancelable(false)
.setPositiveButton("Ok", new OnClickListener() {
@Override public void onClick(DialogInterface dialog, int id) {
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show the alert dialog
alertDialog.show();
}
示例3: showInfoDialog
import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
private void showInfoDialog(int id, String courseName, CourseInfo course) {
selectedCourseNo = course.getCourseNo();
Builder course_dialog_builder = new AlertDialog.Builder(getActivity());
course_dialog_builder.setTitle(courseName);
String message = String.format(Locale.TAIWAN, "%s%s\n%s%s\n%s%s\n%s%s",
getString(R.string.course_courseid), course.getCourseNo(),
getString(R.string.course_classtime), TIME_ARRAY[id - 1],
getString(R.string.course_classplace), course.getCourseRoom(),
getString(R.string.course_classteacher), course.getCourseTeacher());
course_dialog_builder.setMessage(message);
course_dialog_builder.setPositiveButton(R.string.course_classdetail, courseDetailDialogLis);
course_dialog_builder.show();
}
示例4: showDialog
import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
public static void showDialog(String title, String msg, Context context) {
Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title);
builder.setMessage(msg);
builder.setPositiveButton(R.string.back, null);
builder.show();
}
示例5: scanWifi
import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
public void scanWifi() {
if (!checkPermission()) {
if (activityContext instanceof MainActivity) {
((MainActivity) activityContext).requestPermission(Manifest.permission.ACCESS_COARSE_LOCATION, this);
}
return;
}
if (!WifiUtility.isWifiOpen(MainApplication.getInstance())) {
Builder checkDialog = new AlertDialog.Builder(activityContext);
checkDialog.setTitle(R.string.hint);
checkDialog.setMessage(R.string.wifi_needenable);
checkDialog.setPositiveButton(R.string.wifi_enable,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (!isScan) {
isScan = true;
WifiUtility.openWifi(MainApplication
.getInstance());
WifiUtility.startScan(activityContext,
wifiReceiver);
}
}
});
checkDialog.setNegativeButton(R.string.back, null);
checkDialog.show();
} else {
if (!isScan) {
isScan = true;
WifiUtility.startScan(activityContext, wifiReceiver);
}
}
}
示例6: onClick
import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
selectedEvent = (EventInfo) v.getTag(R.id.data_tag);
Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(R.string.activity_detail);
String message = null;
if (selectedEvent.getStartDate().compareTo(selectedEvent.getEndDate()) == 0) {
message = String.format(
Locale.TAIWAN,
"%s\n\n" + getContext().getString(R.string.activity_date) + "%s",
selectedEvent.getEvent(),
Utility.getDateString("yyyy/MM/dd (E)",
selectedEvent.getStartDate(), getContext()));
} else {
message = String.format(
Locale.TAIWAN,
"%s\n\n" + getContext().getString(R.string.activity_startdate) + "%s\n" + getContext().getString(R.string.activity_enddate) + "%s",
selectedEvent.getEvent(),
Utility.getDateString("yyyy/MM/dd (E)",
selectedEvent.getStartDate(), getContext()),
Utility.getDateString("yyyy/MM/dd (E)",
selectedEvent.getEndDate(), getContext()));
}
builder.setMessage(message);
builder.setNegativeButton(R.string.add_to_calendar, this);
builder.setPositiveButton(R.string.share_using, this);
builder.show();
}
示例7: onCreateDialog
import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
@Override
@NonNull
@SuppressLint("InflateParams")
public Dialog onCreateDialog(Bundle savedInstanceState) {
Context context = getActivity();
LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
View view = layoutInflater.inflate(R.layout.entity_field_editor_enum_dialog, null);
listView = (ListView) view.findViewById(R.id.entity_field_editor_enum_dialog_list);
emptyView = (TextView) view.findViewById(R.id.entity_field_editor_enum_dialog_empty_view);
progressBar = (ProgressBar) view.findViewById(R.id.entity_field_editor_enum_dialog_progress_bar);
listView.setOnItemClickListener(this);
tryLoadValues();
Builder builder = new Builder(context);
builder.setNegativeButton(android.R.string.cancel, null);
builder.setView(view);
//Se o fragmento foi restaurado, o editor pode n ter sido setado ainda.
if (editor != null) {
builder.setTitle(editor.getLabel());
} else {
AndroidBugsUtils.applyWorkaroundForAlertDialogWithInvisibleTitleBug(builder);
}
return builder.create();
}
示例8: onCreateDialog
import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
@NonNull
@SuppressLint("InflateParams")
@Override
public AppCompatDialog onCreateDialog(Bundle savedInstanceState)
{
Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("test fragment mode");
oh = getArguments().getString(KEY_OH);
builder.setPositiveButton(android.R.string.ok, null);
return builder.create();
}
示例9: onCreateDialog
import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
Bundle arguments = getArguments();
if (arguments == null) {
throw new IllegalStateException("Arguments are missing");
}
Context context = getActivity();
Builder builder = new Builder(context);
int titleResId = arguments.getInt(TITLE_ARGUMENT);
if (titleResId > 0) {
builder.setTitle(titleResId);
} else {
String title = arguments.getString(TITLE_STRING_ARGUMENT);
if (title != null) {
builder.setTitle(title);
}
}
int viewLayoutId = arguments.getInt(VIEW_LAYOUT_ARGUMENT);
if (viewLayoutId > 0) {
dialogView = LayoutInflater.from(context).inflate(viewLayoutId, null);
if (savedInstanceState != null) {
SparseArray<Parcelable> states = savedInstanceState.getSparseParcelableArray(SAVED_DIALOG_VIEW_STATE);
dialogView.restoreHierarchyState(states);
}
builder.setView(dialogView);
} else {
int msgResId = arguments.getInt(MESSAGE_ARGUMENT);
if (msgResId > 0) {
builder.setMessage(msgResId);
} else {
String message = arguments.getString(MESSAGE_STRING_ARGUMENT);
if (message != null) {
builder.setMessage(message);
}
}
}
builder.setPositiveButton(arguments.getInt(POSITIVE_BUTTON_ARGUMENT, android.R.string.ok), this);
if (arguments.getBoolean(NEGATIVE_BUTTON_VISIBLE_ARGUMENT, true)) {
builder.setNegativeButton(arguments.getInt(NEGATIVE_BUTTON_ARGUMENT, android.R.string.cancel), this);
}
AlertDialog alertDialog = builder.create();
alertDialog.setCanceledOnTouchOutside(arguments.getBoolean(CANCELED_ON_TOUCH_OUTSIDE_ARGUMENT, true));
if (dialogView != null) {
//Tem que definir isto para que o teclado abra na View focada.
alertDialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}
return alertDialog;
}
示例10: onCreateDialog
import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
@Override
@NonNull
@SuppressLint("InflateParams")
public Dialog onCreateDialog(Bundle savedInstanceState) {
//Obtém os argumentos (opcionais)
int titleId = 0;
ArrayList<MessageGroup> messageGroups = null;
Bundle arguments = getArguments();
if (arguments != null) {
titleId = arguments.getInt(DIALOG_TITLE_ARGUMENT);
messageGroups = arguments.getParcelableArrayList(MESSAGE_GROUPS_ARGUMENT);
}
//Cria a View customizada do dialog.
Context context = getActivity();
LayoutInflater layoutInflater = LayoutInflater.from(context);
View view = layoutInflater.inflate(R.layout.entity_editing_message_list_dialog, null);
TextView messageView = (TextView) view.findViewById(R.id.entity_editing_message_list_dialog_text);
if (messageGroups == null || messageGroups.isEmpty()) {
messageView.setText(R.string.entity_editing_message_list_dialog_message_empty);
} else {
messageView.setText(R.string.entity_editing_message_list_dialog_message);
//Só define o adapter se houver mensagens.
ListView listView = (ListView) view.findViewById(R.id.entity_editing_message_list_dialog_list);
listView.setAdapter(new MessageAdapter(context, messageGroups));
}
Builder builder = new Builder(context);
builder.setPositiveButton(android.R.string.ok, null);
builder.setView(view);
//Define o título do dialog, se houver.
if (titleId != 0) {
builder.setTitle(titleId);
}
AlertDialog dialog = builder.create();
AndroidBugsUtils.applyWorkaroundForAlertDialogWithFlexibleListViewBug(dialog, view);
return dialog;
}
示例11: showTransport
import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
private void showTransport() {
//TODO : Do this properly
Builder b = new Builder(this);
b.setTitle("Select default route");
String[] types = new String[routeDataList.size()];
for (RouteData s : routeDataList) {
types[routeDataList.indexOf(s)] = s.getOrigin().toUpperCase() + "-" + s.getDestination().toUpperCase() + " " + s.getType();
if (s.getFavorite().equals("yes")) {
types[routeDataList.indexOf(s)] = types[routeDataList.indexOf(s)] + " (default)";
}
}
b.setPositiveButton(cancel, new OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
b.setItems(types, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
prefs.setFavoriteOrigin(routeDataList.get(which).getOrigin());
prefs.setFavoriteDestination(routeDataList.get(which).getDestination());
prefs.setFavoriteType(routeDataList.get(which).getType());
CommonTasks.sendFavoriteRoute(getApplicationContext(), routeDataList.get(which).getRouteID());
prefs.defaultRouteSet();
for (int i = 0; i < routeDataList.size(); i++) {
if (i == which) {
routeDataList.get(i).setFavorite("yes");
} else {
routeDataList.get(i).setFavorite("no");
}
}
dialog.dismiss();
setUpItems();
Snackbar snackbar = Snackbar.make(recyclerView, "Default route changed!", BaseTransientBottomBar.LENGTH_SHORT);
snackbar.getView().setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.green));
snackbar.show();
}
});
b.show();
}
示例12: onCreateDialog
import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
@NonNull
@SuppressLint("InflateParams")
@Override
public AppCompatDialog onCreateDialog(Bundle savedInstanceState) {
int title = getArguments().getInt(TITLE);
final int min = getArguments().getInt(MIN);
final int max = getArguments().getInt(MAX);
int startCurrent = getArguments().getInt(START_CURRENT);
int endCurrent = getArguments().getInt(END_CURRENT);
final SetRangeListener listener = (SetRangeListener) getParentFragment();
// Preferences prefs= new Preferences(getActivity());
Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(title);
final LayoutInflater inflater = getActivity().getLayoutInflater(); // ThemeUtils.getLayoutInflater(getActivity());
// DoNothingListener doNothingListener = new DoNothingListener();
View layout = inflater.inflate(R.layout.rangepicker, null);
builder.setView(layout);
String[] startValues = new String[max - min + 1];
for (int i = min; i <= max; i++) {
startValues[i - min] = Integer.toString(i);
}
final NumberPickerView npvStart = (NumberPickerView) layout.findViewById(R.id.start);
npvStart.setDisplayedValues(startValues);
npvStart.setMinValue(min);
npvStart.setMaxValue(max);
npvStart.setValue(startCurrent);
String[] endValues = new String[max - min + 2];
endValues[0] = "-";
for (int i = min; i <= max; i++) {
endValues[i - min + 1] = Integer.toString(i);
}
final NumberPickerView npvEnd = (NumberPickerView) layout.findViewById(R.id.end);
npvEnd.setDisplayedValues(endValues);
npvEnd.setMinValue(min - 1);
npvEnd.setMaxValue(max);
if (endCurrent == NOTHING_SELECTED) {
endCurrent = min - 1;
}
npvEnd.setValue(endCurrent);
builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int endValue = npvEnd.getValue();
if (endValue == min - 1) {
endValue = NOTHING_SELECTED;
}
listener.setRange(npvStart.getValue(), endValue);
}
});
builder.setNeutralButton(android.R.string.cancel, null);
return builder.create();
}
示例13: onCreateDialog
import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
@NonNull
@SuppressLint("InflateParams")
@Override
public AppCompatDialog onCreateDialog(Bundle savedInstanceState) {
int title = getArguments().getInt(TITLE);
int startHour = getArguments().getInt(START_HOUR);
int startMinute = getArguments().getInt(START_MINUTE);
int endHour = getArguments().getInt(END_HOUR);
int endMinute = getArguments().getInt(END_MINUTE);
boolean startOnly = getArguments().getBoolean(START_ONLY);
final SetTimeRangeListener listener = (SetTimeRangeListener) getParentFragment();
// Preferences prefs= new Preferences(getActivity());
Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(title);
final LayoutInflater inflater = getActivity().getLayoutInflater(); // ThemeUtils.getLayoutInflater(getActivity());
// DoNothingListener doNothingListener = new DoNothingListener();
View layout = inflater.inflate(R.layout.timerangepicker, null);
builder.setView(layout);
String[] hourValues = new String[48];
for (int i = 0; i < 48; i++) {
hourValues[i] = String.format("%02d", i);
}
final NumberPickerView npvStartHour = (NumberPickerView) layout.findViewById(R.id.startHour);
npvStartHour.setDisplayedValues(hourValues);
npvStartHour.setMinValue(0);
npvStartHour.setMaxValue(23);
npvStartHour.setValue(startHour);
String[] minValues = new String[60];
for (int i = 0; i < 60; i++) {
minValues[i] = String.format("%02d", i);
}
final NumberPickerView npvStartMinute = (NumberPickerView) layout.findViewById(R.id.startMinute);
npvStartMinute.setDisplayedValues(minValues);
npvStartMinute.setMinValue(0);
npvStartMinute.setMaxValue(59);
npvStartMinute.setValue(startMinute);
final NumberPickerView npvEndHour = (NumberPickerView) layout.findViewById(R.id.endHour);
final NumberPickerView npvEndMinute = (NumberPickerView) layout.findViewById(R.id.endMinute);
if (startOnly) {
npvEndHour.setVisibility(View.GONE);
npvEndMinute.setVisibility(View.GONE);
} else {
npvEndHour.setVisibility(View.VISIBLE);
npvEndMinute.setVisibility(View.VISIBLE);
npvEndHour.setDisplayedValues(hourValues);
npvEndHour.setMinValue(0);
npvEndHour.setMaxValue(47);
npvEndHour.setValue(endHour);
npvEndMinute.setDisplayedValues(minValues);
npvEndMinute.setMinValue(0);
npvEndMinute.setMaxValue(59);
npvEndMinute.setValue(endMinute);
}
builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int startHourValue = npvStartHour.getValue();
int startMinuteValue = npvStartMinute.getValue();
int endHourValue = npvEndHour.getValue();
int endMinuteValue = npvEndMinute.getValue();
listener.setTimeRange(startHourValue, startMinuteValue, endHourValue, endMinuteValue);
}
});
builder.setNeutralButton(android.R.string.cancel, null);
return builder.create();
}
示例14: applyWorkaroundForAlertDialogWithInvisibleTitleBug
import android.support.v7.app.AlertDialog.Builder; //导入方法依赖的package包/类
/**
* Contorno para o bug em que um {@link AlertDialog} que foi construído sem título não mostra o título que foi setado posteriormente (através
* do {@link AlertDialog#setTitle(CharSequence)}. O problema acontece porque o AlertDialog esconde a View que exibe o título se este valor
* não for definido no momento de sua construção. Desta forma, se o título for definido posteriormente ele simplesmente não aparece.
* O correto seria a View ter sua visibilidade alterada no momento da definição do novo título.<br>
* O contorno faz com que seja definido um texto temporário como titulo, fazendo com que a View do titulo seja criada.<br>
* <br>
* Este contorno só deve ser utilizado se o titulo do AlertDialog for definido logo após sua criação.
*
* @param dialogBuilder construtor de AlertDialog.
*/
public static void applyWorkaroundForAlertDialogWithInvisibleTitleBug(Builder dialogBuilder) {
dialogBuilder.setTitle(" ");
}