當前位置: 首頁>>代碼示例>>Java>>正文


Java AlertDialog.setTitle方法代碼示例

本文整理匯總了Java中android.app.AlertDialog.setTitle方法的典型用法代碼示例。如果您正苦於以下問題:Java AlertDialog.setTitle方法的具體用法?Java AlertDialog.setTitle怎麽用?Java AlertDialog.setTitle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.AlertDialog的用法示例。


在下文中一共展示了AlertDialog.setTitle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import android.app.AlertDialog; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    Boolean isFlashAvailable = getApplicationContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
    if (!isFlashAvailable) {
        AlertDialog alert = new AlertDialog.Builder(MainActivity.this).create();
        alert.setTitle(getString(R.string.app_name));
        alert.setMessage("Error");
        alert.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
        alert.show();
    }

    Intent i = new Intent(this, BackgroundService.class);
    startService(i);
    Log.d("ProjectLumen","loaded");

}
 
開發者ID:indianpoptart,項目名稱:ProjectLumen,代碼行數:25,代碼來源:MainActivity.java

示例2: deleteAllCalls

import android.app.AlertDialog; //導入方法依賴的package包/類
private void deleteAllCalls() {
    AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
    alertDialog.setTitle(R.string.callLog_delDialog_title);
    alertDialog.setMessage(getString(R.string.callLog_delDialog_message));
    alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.callLog_delDialog_yes),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    getActivity().getContentResolver().delete(SipManager.CALLLOG_URI, null,
                            null);
                }
            });
    alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.callLog_delDialog_no),
            (DialogInterface.OnClickListener) null);
    try {
        alertDialog.show();
    } catch (Exception e) {
        Log.e(THIS_FILE, "error while trying to show deletion yes/no dialog");
    }
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:20,代碼來源:CallLogListFragment.java

示例3: onBind

import android.app.AlertDialog; //導入方法依賴的package包/類
@Override
public IBinder onBind(Intent intent) {

    // First check if device has a light sensor or not
    HasLightSensor = getApplicationContext().getPackageManager()
            .hasSystemFeature(PackageManager.FEATURE_SENSOR_LIGHT);

    if (!HasLightSensor) {
        // device doesn't support light sensor
        // Show alert message and close the application
        AlertDialog alert = new AlertDialog.Builder(cSunService.this)
                .create();
        alert.setTitle("Error");
        alert.setMessage("Sorry, your device doesn't support SUN! as it has no light sensor");
    } else
        getBrightMode(getContentResolver());

    return null;
}
 
開發者ID:hamedbaatour,項目名稱:cSun,代碼行數:20,代碼來源:cSunService.java

示例4: commonAlertDialog

import android.app.AlertDialog; //導入方法依賴的package包/類
public static void commonAlertDialog(Context parent, String title, String message) {

        AlertDialog alertDialog = new AlertDialog.Builder(parent, AlertDialog.THEME_HOLO_DARK).create();
        alertDialog.setTitle(title);

        alertDialog.setMessage(Html.fromHtml(message));
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }
        );

        alertDialog.show();
    }
 
開發者ID:Samsung,項目名稱:microbit,代碼行數:17,代碼來源:CommonGUI.java

示例5: showAlertDialog

import android.app.AlertDialog; //導入方法依賴的package包/類
public void showAlertDialog(Context context, String title, String message,
                            Boolean status) {
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);
    alertDialog.setMessage(message);
    if(status != null)
        alertDialog.setIcon((status) ? R.drawable.success : R.drawable.fail);
        alertDialog.setButton("Тийм", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    alertDialog.show();
}
 
開發者ID:tortuvshin,項目名稱:actions,代碼行數:14,代碼來源:AlertDialogManager.java

示例6: alert

import android.app.AlertDialog; //導入方法依賴的package包/類
public static void alert(final Object context,
    final String message, final String title,final String buttonText) {
  Log.i("RuntimeErrorAlert", "in alert");
  AlertDialog alertDialog = new AlertDialog.Builder((Context) context).create();
  alertDialog.setTitle(title);
  alertDialog.setMessage(message);
  alertDialog.setButton(buttonText, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
      ((Activity) context).finish();
    }});
  if (message == null) {
    // Avoid passing null to Log.e, which would cause a NullPointerException.
    Log.e(RuntimeErrorAlert.class.getName(), "No error message available");
  } else {
    Log.e(RuntimeErrorAlert.class.getName(), message);
  }
  alertDialog.show();
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:19,代碼來源:RuntimeErrorAlert.java

示例7: onRequestPermissionsResult

import android.app.AlertDialog; //導入方法依賴的package包/類
@Override
public void onRequestPermissionsResult(int requestCode,
                                       String permissions[], int[] grantResults) {
    switch (requestCode) {
        case MY_PERMISSIONS_REQUEST_LOCATION: {
            // If request is cancelled, the result arrays are empty.
            if (grantResults.length > 0
                    && grantResults[0] == PackageManager.PERMISSION_GRANTED) {

                // permission was granted
                if (ContextCompat.checkSelfPermission(this,
                        android.Manifest.permission.ACCESS_FINE_LOCATION)
                        == PackageManager.PERMISSION_GRANTED) {
                    if (mGoogleApiClient == null) {
                        buildGoogleApiClient();
                    }
                    mMap.setMyLocationEnabled(true);
                }
            } else {
                // Permission denied, show alert
                AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
                alertDialog.setTitle("Alert");
                alertDialog.setMessage("Please allow the location permission!");
                alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                                checkLocationPermission();
                            }
                        });
                alertDialog.show();
            }
            return;
        }
    }
}
 
開發者ID:armendu,項目名稱:traffic-report-android,代碼行數:37,代碼來源:MainActivity.java

示例8: createRateDialog

import android.app.AlertDialog; //導入方法依賴的package包/類
public static Dialog createRateDialog(Context context,
                                      DialogInterface.OnClickListener onClickListener) {
    AlertDialog rateDialog = new AlertDialog.Builder(context).create();
    rateDialog.setTitle(context.getString(R.string.dialog_rate_app_title));
    rateDialog.setMessage(context.getString(R.string.dialog_rate_app_text));
    rateDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.dialog_positive_button_text), onClickListener);
    rateDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.dialog_negative_button_text), onClickListener);
    rateDialog.setButton(AlertDialog.BUTTON_NEUTRAL, context.getString(R.string.dialog_neutral_button_text), onClickListener);
    return rateDialog;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:DialogFactory.java

示例9: showAlert

import android.app.AlertDialog; //導入方法依賴的package包/類
/**
 * 展示一個通用的彈出框UI
 *
 * @param context 展示彈出框的上下文環境
 * @param title   警告的title信息
 * @param text    警告信息
 */
public static void showAlert(Context context, String title, String text) {
    AlertDialog alertDialog = new Builder(context).create();
    alertDialog.setTitle(title);
    alertDialog.setMessage(text);
    alertDialog.setCanceledOnTouchOutside(true);
    alertDialog.show();
}
 
開發者ID:dueros,項目名稱:dcs-sdk-java,代碼行數:15,代碼來源:CommonUtil.java

示例10: showErrorDialog

import android.app.AlertDialog; //導入方法依賴的package包/類
private void showErrorDialog(String message) {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Error!");
    alertDialog.setMessage(message);
    alertDialog.setIcon(android.R.drawable.alert_dark_frame);
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            MainActivity.this.finish();
        }
    });

    alertDialog.show();
}
 
開發者ID:PacktPublishing,項目名稱:Java-9-Programming-Blueprints,代碼行數:15,代碼來源:MainActivity.java

示例11: renameFile

import android.app.AlertDialog; //導入方法依賴的package包/類
/**
 * Allows to rename file by given file path and a new file name.
 *
 * @param filePath Full path to the file.
 * @param newName  New name of the file.
 */
public void renameFile(String filePath, String newName) {

    FileUtils.RenameResult renameResult = FileUtils.renameFile(filePath, newName);
    if(renameResult != FileUtils.RenameResult.SUCCESS) {
        AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle("Alert");

        String message = "OOPS!";
        switch(renameResult) {
            case NEW_PATH_ALREADY_EXIST:
                message = "Cannot rename, destination file already exists.";
                break;

            case OLD_PATH_NOT_CORRECT:
                message = "Cannot rename, source file not exist.";
                break;

            case RENAME_ERROR:
                message = "Rename operation failed.";
                break;
        }

        alertDialog.setMessage(message);
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });

        alertDialog.show();
    } else {
        updateProjectsListSortOrder(true);
    }
}
 
開發者ID:Samsung,項目名稱:microbit,代碼行數:42,代碼來源:ProjectActivity.java

示例12: showAlertDialog

import android.app.AlertDialog; //導入方法依賴的package包/類
private void showAlertDialog(String message) {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Alert");
    alertDialog.setMessage(message);
    alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}
 
開發者ID:freeloki,項目名稱:AndroidThings-BurglarAlarm,代碼行數:13,代碼來源:BurglarActivity.java

示例13: oneButtonAlert

import android.app.AlertDialog; //導入方法依賴的package包/類
public static void oneButtonAlert(Activity activity,String message, String title, String buttonText) {
  Log.i(LOG_TAG, "One button alert " + message);
  AlertDialog alertDialog = new AlertDialog.Builder(activity).create();
  alertDialog.setTitle(title);
  // prevents the user from escaping the dialog by hitting the Back button
  alertDialog.setCancelable(false);
  alertDialog.setMessage(stringToHTML(message));
  alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL,
      buttonText, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
    }});
  alertDialog.show();
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:14,代碼來源:Notifier.java

示例14: showAlert

import android.app.AlertDialog; //導入方法依賴的package包/類
/**
 * Show dialog
 * @param context Context
 * @param title Title
 * @param layoutResource Layout resource id
 * @param iconResource Icon resource id
 * @return AlertDialog Dialog
 */
static AlertDialog showAlert(Context context, CharSequence title, int layoutResource, int iconResource) {
    @SuppressLint("InflateParams")
    View view = ((Activity) context).getLayoutInflater().inflate(layoutResource, null, false);
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);
    alertDialog.setView(view);
    if (iconResource > 0) {
        alertDialog.setIcon(iconResource);
    }
    alertDialog.show();
    return alertDialog;
}
 
開發者ID:bfabiszewski,項目名稱:ulogger-android,代碼行數:21,代碼來源:Alert.java

示例15: showInfo

import android.app.AlertDialog; //導入方法依賴的package包/類
/**
 * Shows an info dialog.
 * 
 * @param context
 *            {@link Context}
 * @param msg
 *            the message.
 * @param listener
 *            the {@link DialogInterface.OnDismissListener}.
 */
public static void showInfo(Context context, CharSequence msg,
        DialogInterface.OnDismissListener listener) {
    AlertDialog dlg = newAlertDlg(context);
    dlg.setIcon(android.R.drawable.ic_dialog_info);
    dlg.setTitle(R.string.afc_title_info);
    dlg.setMessage(msg);
    dlg.setOnDismissListener(listener);
    dlg.show();
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:20,代碼來源:Dlg.java


注:本文中的android.app.AlertDialog.setTitle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。