当前位置: 首页>>代码示例>>Java>>正文


Java AlertDialog.setTitle方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:LewisVo,项目名称:Overkill,代码行数:18,代码来源:MainActivity.java

示例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();
        }
    }
}
 
开发者ID:LewisVo,项目名称:Overkill,代码行数:19,代码来源:MainActivity.java

示例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();
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:19,代码来源:GoalsDetailedDialog.java

示例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);
}
 
开发者ID:LewisVo,项目名称:Minitask,代码行数:23,代码来源:AddTodoItem.java

示例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);
}
 
开发者ID:LewisVo,项目名称:Minitask,代码行数:23,代码来源:AddTodoItem.java

示例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();
}
 
开发者ID:serhataras,项目名称:Roomie,代码行数:14,代码来源:BackpackActivity.java

示例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);
    }
}
 
开发者ID:BakkerTom,项目名称:happy-news,代码行数:34,代码来源:PostFragment.java

示例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();
}
 
开发者ID:zhanghangyes,项目名称:updateUtils,代码行数:39,代码来源:UpdateAgent.java

示例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();
    }
}
 
开发者ID:Q115,项目名称:Goalie_Android,代码行数:15,代码来源:NewGoalFragment.java

示例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();
}
 
开发者ID:Welloculus,项目名称:MobileAppForPatient,代码行数:29,代码来源:RegisterUser.java

示例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();
}
 
开发者ID:simoneapp,项目名称:S3-16-simone,代码行数:13,代码来源:FullscreenBaseGameActivity.java

示例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);
}
 
开发者ID:GabrielMorenoIbarra,项目名称:BackendDrivenMenu,代码行数:30,代码来源:MainActivity.java

示例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;
}
 
开发者ID:karanjadhav2508,项目名称:kqsse17,代码行数:13,代码来源:AlertDialogHelper.java

示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:42,代码来源:UpdateAgent.java

示例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();
    }

}
 
开发者ID:ThomasDelaney,项目名称:TapIn,代码行数:69,代码来源:employeeTimetable.java


注:本文中的android.support.v7.app.AlertDialog.setTitle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。