本文整理汇总了Java中android.support.v7.app.AlertDialog.setMessage方法的典型用法代码示例。如果您正苦于以下问题:Java AlertDialog.setMessage方法的具体用法?Java AlertDialog.setMessage怎么用?Java AlertDialog.setMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.app.AlertDialog
的用法示例。
在下文中一共展示了AlertDialog.setMessage方法的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: 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();
}
}
示例9: 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();
}
示例10: 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();
}
示例11: 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();
}
}
示例12: onItem
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@Override
public void onItem(int index) {
if (!networkControl()){
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle("İnternet Yok !");
alertDialog.setMessage("Lütfen internet bağlantısını kontrol ediniz.");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "Tamam",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
}else{
String[] cafeterias = getResources().getStringArray(R.array.cafeterias);
TextView tvCafeterias = toolbar.findViewById(R.id.tvCafeterias);
tvCafeterias.setText(cafeterias[index]);
Eat eat = new Eat();
if (eatList.getEats().size() != 0){
eat = eatList.getEats().get(index);
Bundle bundle = new Bundle();
bundle.putSerializable("eat", eat);
transaction = fragmentManager.beginTransaction();
CafeteriaDetailFragment cafeteriaDetailFragment = new CafeteriaDetailFragment();
cafeteriaDetailFragment.setArguments(bundle);
transaction.replace(R.id.container , cafeteriaDetailFragment);
transaction.addToBackStack(null);
transaction.commit();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
fragmentManager.popBackStack();
reNameTitle();
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
}
});
}
}
}
示例13: onCreateDialog
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final AlertDialog dialog = (AlertDialog) super.onCreateDialog(savedInstanceState);
layoutInflater = dialog.getLayoutInflater();
View content = onCreateContentView(savedInstanceState);
// Intermediate view with custom message TextView
View intermediate = inflate(R.layout.simpledialogfragment_custom_view);
TextView textView = (TextView) intermediate.findViewById(R.id.customMessage);
View topSpacer = intermediate.findViewById(R.id.textSpacerNoTitle);
ViewGroup container = (ViewGroup) intermediate.findViewById(R.id.customView);
container.addView(content);
dialog.setView(intermediate);
String msg = getArgString(MESSAGE);
if (msg != null) {
CharSequence message;
if (getArguments().getBoolean(HTML)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
message = Html.fromHtml(msg, 0);
} else {
//noinspection deprecation
message = Html.fromHtml(msg);
}
} else {
message = msg;
}
textView.setText(message);
} else {
textView.setVisibility(View.GONE);
}
dialog.setMessage(null);
topSpacer.setVisibility(getArgString(TITLE) == null && msg != null ? View.VISIBLE : View.GONE);
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface d) {
positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
positiveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pressPositiveButton();
}
});
onDialogShown();
}
});
return dialog;
}
示例14: sendTime
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
private void sendTime() {
if (switchOpen) {
final AlertDialog dialog = new AlertDialog.Builder(this).create();
dialog.setTitle(getResources().getString(R.string.remind));
dialog.setMessage(getResources().getString(R.string.wait));
dialog.show();
Calendar c = Calendar.getInstance();
int hour = c.get(Calendar.HOUR_OF_DAY);
int min = c.get(Calendar.MINUTE);
String hourStr = hour + "";
String minStr = min + "";
if (hour < 10) {
hourStr = "0" + hour + "";
}
if (min < 10) {
minStr = "0" + min + "";
}
ControlLight.sendTime(CommandUtils.TIMING_CURRENT, hourStr, minStr);
startAPM.postDelayed(new Runnable() {
@Override
public void run() {
ControlLight.sendTime(CommandUtils.TIMING_ON_1, time[0], time[1]);
startAPM.postDelayed(new Runnable() {
@Override
public void run() {
ControlLight.sendTime(CommandUtils.TIMING_ON_2, time[2], time[3]);
dialog.cancel();
finishThis();
}
}, 1000);
}
}, 1000);
} else {
ControlLight.sendOrder(CommandUtils.TIMING_OFF);
finishThis();
}
}
示例15: initUI
import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@Override
protected void initUI() {
AlertDialog alertDialog = new AlertDialog.Builder(SettingsActivity.this).create();
alertDialog.setTitle("Message");
final Intent changePssActivity = new Intent(this, DashboardActivity.class);
alertDialog.setMessage("Call your API for setting device send timeout");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
startActivity(changePssActivity);
finish();
}
});
alertDialog.show();
mNewSettings = new CognitoUserSettings();
settingsChanged = false;
// mSmsSwitch = (Switch) findViewById(R.id.switchSettingsPhone);
mTxtDataIntervalTitle = (TextView) findViewById(R.id.textViewDataIntervalTitle);
mTxtDataIntervalValue = (TextView) findViewById(R.id.textViewDataIntervalValue);
//mSettings = CognitoHelper.getUserDetails().getSettings().getSettings();
if (mSmsSwitch != null) {
mSmsSwitch.setClickable(true);
mSmsSwitch.setChecked(false);
mSmsSwitch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
toggleSwitch();
if (mSmsSwitch.isChecked()) {
updateSetting(Constants.phoneNumber, Constants.SMS1);
} else {
updateSetting(Constants.phoneNumber, null);
}
}
});
}
if (mSettings != null) {
if (mSettings.containsKey(Constants.phoneNumber) && mSmsSwitch != null) {
mSmsSwitch.setClickable(true);
if (mSettings.get(Constants.phoneNumber).contains(Constants.SMS) || mSettings.get(Constants.phoneNumber).contains(Constants.SMS1)) {
mSmsSwitch.setChecked(true);
mSmsSwitch.setTextColor(Color.parseColor("#37A51C"));
} else {
mSmsSwitch.setChecked(false);
mSmsSwitch.setTextColor(Color.parseColor("#E94700"));
}
}
}
}