本文整理汇总了Java中android.support.v7.app.AlertDialog.setTitle方法的典型用法代码示例。如果您正苦于以下问题:Java AlertDialog.setTitle方法的具体用法?Java AlertDialog.setTitle怎么用?Java AlertDialog.setTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.app.AlertDialog
的用法示例。
在下文中一共展示了AlertDialog.setTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkInternetConnection
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
private void checkInternetConnection() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if ( netInfo == null || !netInfo.isConnectedOrConnecting() ) {
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle("Warning");
alertDialog.setMessage("This app has limited functions without the internet connection.");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
}
}
示例2: onRequestPermissionsResult
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == MYPERMISSION) {
if (grantResults.length < 0 || grantResults[0] != PackageManager.PERMISSION_GRANTED) {
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle("Please!!");
alertDialog.setMessage("ALLOW map permission.");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
}
}
}
示例3: delete
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
private void delete() {
AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
alertDialog.setTitle(getString(R.string.are_you_sure));
alertDialog.setMessage(getString(R.string.no_refund));
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
GoalHelper.getInstance().deleteGoal(mGuid);
Intent returnIntent = new Intent();
String goalCompleteResultString = String.valueOf(Goal.GoalCompleteResult.Cancelled.ordinal());
returnIntent.putExtra("goalCompleteResultInt", goalCompleteResultString);
getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, returnIntent);
dismiss();
}
});
alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), (DialogInterface.OnClickListener) null);
alertDialog.show();
}
示例4: onDateSet
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@Override
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
// if the date is in the past tell user to choose again
if (dateTimeUtils.checkInvalidDate(year, monthOfYear, dayOfMonth)){
AlertDialog alertDialog = new AlertDialog.Builder(AddTodoItem.this).create();
alertDialog.setTitle("Date not valid!");
alertDialog.setIcon(R.drawable.ic_warning_black_24dp);
alertDialog.setMessage("You are selecting a time a point of time in the past!");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
return;
}
// set date value to the value user selected and change the text
date = dateTimeUtils.dateToString(year, monthOfYear, dayOfMonth);
reminderText.setText(getString(R.string.reminder_set_at) + " " + date + " " + time);
}
示例5: onTimeSet
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@Override
public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute, int second) {
// if date is not chosen first but time is chosen -> make today the default date.
// also check for valid time, must be today but not the past hour or minutes.
if (date.equals(dateTimeUtils.fillDateIfEmpty("")) && dateTimeUtils.checkInvalidTime(hourOfDay, minute)) {
AlertDialog alertDialog = new AlertDialog.Builder(AddTodoItem.this).create();
alertDialog.setTitle("Time not valid!");
alertDialog.setMessage("You are selecting a point of time in the past!");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
return;
}
// set time value and update text
time = dateTimeUtils.timeToString(hourOfDay, minute);
reminderText.setText(getString(R.string.reminder_set_at) + " " + date + " " + time);
}
示例6: showDialog
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
private void showDialog(String message)
{
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Warning!");
alertDialog.setMessage(message);
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
}
示例7: refresh
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
/**
* Refresh the content.
*
* <p>Shows an error message when the app is not connected to the internet.
*/
protected void refresh() {
ConnectivityManager connectivityManager = (ConnectivityManager) getActivity().getSystemService(Context
.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null && activeNetwork.isConnected();
if (!isConnected) {
AlertDialog alert = new AlertDialog.Builder(getActivity()).create();
alert.setTitle(getString(R.string.network_error_title));
alert.setMessage(getString(R.string.no_internet_message));
alert.setButton(RESULT_OK, getString(R.string.retry_button), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//Display an error if still not connected
refresh();
}
});
alert.show();
} else {
swipeRefresh.setRefreshing(true);
loading = true;
doRefresh(postManager, refreshCallback);
}
}
示例8: onPrompt
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@Override
public void onPrompt(UpdateAgent agent) {
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 OnPromptClick(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();
}
示例9: onSetGoal
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@Override
public void onSetGoal(boolean isSuccessful, String errMsg) {
if (isSuccessful) {
Toast.makeText(getActivity(), getString(R.string.ok_goal), Toast.LENGTH_SHORT).show();
getActivity().setResult(Activity.RESULT_OK);
getActivity().finish();
} else {
AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
alertDialog.setTitle(getString(R.string.error_goal));
alertDialog.setMessage(errMsg);
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok), (DialogInterface.OnClickListener) null);
alertDialog.show();
}
}
示例10: initUI
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@Override
protected void initUI() {
mScrollView = (ScrollView) findViewById(R.id.scroll_register_user);
initUserName();
initPassword();
initGivenName();
initEmail();
initPhone();
initFamilyName();
initGenderSpinner();
initBirthDate();
initCity();
initButtonSignUp();
AlertDialog alertDialog = new AlertDialog.Builder(RegisterUser.this).create();
alertDialog.setTitle("Message");
final Intent changePssActivity = new Intent(this, LoginActivity.class);
alertDialog.setMessage("Call your API for Register your User");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
startActivity(changePssActivity);
finish();
}
});
alertDialog.show();
}
示例11: showConnectionErrorDialog
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
private void showConnectionErrorDialog(){
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Connection error");
alertDialog.setMessage("Simone was not able to reach Google Games. Enable connection to improve your experience with Simone.");
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
}
示例12: onOptionsItemSelected
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.about) {
final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle(getString(R.string.about_title));
ImageView iv = new ImageView(this);
int p = G.dpToPx(this, 10);
iv.setPadding(p, G.dpToPx(this, 20), p, p);
iv.setImageDrawable(logo);
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
visitWeb();
alertDialog.hide();
}
});
alertDialog.setView(iv);
alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.visit_web), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
visitWeb();
}
});
alertDialog.setCancelable(true);
alertDialog.show();
return true;
}
return super.onOptionsItemSelected(item);
}
示例13: buildAlertDialog
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
public static AlertDialog buildAlertDialog(Context ctx, String title, String button) {
AlertDialog ad = new AlertDialog.Builder(ctx).create();
ad.setTitle(title);
ad.setButton(AlertDialog.BUTTON_NEUTRAL, button,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}
);
return ad;
}
示例14: prompt
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@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();
}
示例15: getCurrentEmployees
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
public void getCurrentEmployees()
{
final ArrayList<String> info = new ArrayList<String>();
BackgroundTask backgroundTask = new BackgroundTask(new BackgroundTask.AsyncResponse()
{
@Override
public void processFinish(String output)
{
if (output.equals("null"))
{
spinner.setVisibility(View.INVISIBLE);
AlertDialog alertDialog = new AlertDialog.Builder(employeeTimetable.this).create();
alertDialog.setTitle("Sorry");
alertDialog.setMessage("Some has gone wrong. Please Try Again Later");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "Okay",
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
Intent intent2 = new Intent(getApplicationContext(), EmployerMain.class);
intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent2);
finish();
}
});
alertDialog.show();
}
else
{
String[] tokens = output.split("-");
for (String t : tokens)
{
info.add(t);
}
for (int i = 0; i < info.size(); i++)
{
String employee = info.get(i);
String[] splitInfo = employee.split(",");
Employee n = new Employee(i, splitInfo[0], splitInfo[1], splitInfo[2], splitInfo[3], splitInfo[4], splitInfo[5]);
currentEmployees.add(n);
}
spinner.setVisibility(View.INVISIBLE);
scroll = new EmployeeScroll(getApplicationContext(), currentEmployees, 1);
listView.setAdapter(scroll);
scroll.day = day;
scroll.month = month;
}
}
});
if( BackgroundTask.isNetworkAvailable(employeeTimetable.this))
{
backgroundTask.execute("eWorkingCheck", cid, day, month);
}
else
{
finish();
Toast.makeText(employeeTimetable.this,"No internet connection", Toast.LENGTH_LONG ).show();
}
}